Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncrispyfy AlertWidgetForm in navlets #3040

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions python/nav/web/navlets/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

from django import forms

from crispy_forms.helper import FormHelper
from crispy_forms_foundation import layout

from nav.models.manage import Sensor, Room

from nav.web.crispyforms import set_flat_form_attributes, FlatFieldset


class AlertWidgetForm(forms.Form):
"""Form for the alert widget"""
Expand Down Expand Up @@ -42,14 +41,17 @@ def __init__(self, *args, **kwargs):
)
]

self.helper = FormHelper()
self.helper.form_tag = False
self.helper.layout = layout.Layout(
'on_message',
'off_message',
layout.Fieldset('Choose sensor or fill in metric', 'sensor', 'metric'),
'on_state',
'alert_type',
self.attrs = set_flat_form_attributes(
form_fields=[
self['on_message'],
self['off_message'],
FlatFieldset(
legend='Choose sensor or fill in metric',
fields=[self['sensor'], self['metric']],
),
self['on_state'],
self['alert_type'],
]
)

def clean(self):
Expand Down
7 changes: 5 additions & 2 deletions python/nav/web/templates/navlets/alert_edit.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% extends 'navlets/base.html' %}
{% load crispy_forms_tags %}

{% block navlet-content %}

Expand All @@ -13,7 +12,11 @@
</p>

<form action="{% url 'get-user-navlet' navlet.navlet_id %}" method="post">
{% crispy form %}
{% if form.attrs %}
{% include 'custom_crispy_templates/_form_content.html' %}
{% else %}
{{ form }}
{% endif %}
<input type="submit" class="button tiny" value="Save">
<a class="button tiny secondary cancel-button">Cancel</a>
</form>
Expand Down
Loading