diff --git a/python/nav/web/seeddb/forms/__init__.py b/python/nav/web/seeddb/forms/__init__.py index 594dd679b9..1764fd94a7 100644 --- a/python/nav/web/seeddb/forms/__init__.py +++ b/python/nav/web/seeddb/forms/__init__.py @@ -129,25 +129,6 @@ def cut_branch(field, klass, pk): # non-crispy helpers -def set_filter_form_attributes( - legend, - submit_value='Filter', - form_action='', - form_method='get', - form_class='custom', -): - class Obj: - pass - - obj = Obj() - obj.legend = legend - obj.submit_value = submit_value - obj.action = form_action - obj.method = form_method - obj.form_class = form_class - return obj - - def get_single_layout(heading, row): """Get default layout for a single filter""" return set_flat_form_attributes( @@ -184,10 +165,13 @@ class RoomFilterForm(forms.Form): """Form for filtering rooms""" location = forms.ModelChoiceField( - Location.objects.order_by('id').all(), required=False, label_suffix='' + Location.objects.order_by('id').all(), required=False ) location.widget.attrs.update({"class": "select"}) - no_crispy = set_filter_form_attributes('Filter rooms') + + def __init__(self, *args, **kwargs): + super(RoomFilterForm, self).__init__(*args, **kwargs) + self.attrs = get_single_layout(heading="Filter rooms", row=self["location"]) class RoomForm(forms.ModelForm): @@ -302,10 +286,11 @@ class OrganizationMoveForm(forms.Form): class NetboxTypeFilterForm(forms.Form): """Form for filtering a netbox type by vendor""" - vendor = forms.ModelChoiceField( - Vendor.objects.order_by('id').all(), required=False, label_suffix='' - ) - no_crispy = set_filter_form_attributes('Filter types') + vendor = forms.ModelChoiceField(Vendor.objects.order_by('id').all(), required=False) + + def __init__(self, *args, **kwargs): + super(NetboxTypeFilterForm, self).__init__(*args, **kwargs) + self.attrs = get_single_layout(heading="Filter types", row=self["vendor"]) class NetboxTypeForm(forms.ModelForm): diff --git a/python/nav/web/templates/seeddb/_filter_form.html b/python/nav/web/templates/seeddb/_filter_form.html deleted file mode 100644 index 833bf75628..0000000000 --- a/python/nav/web/templates/seeddb/_filter_form.html +++ /dev/null @@ -1,24 +0,0 @@ -
-
- {{ attrs.legend }} -
-
- {% for field in filter_form %} -
- {{ field.label_tag }} - {{ field }} - {% for error in field.errors %} - - {{ error }} - - {% endfor %} -
- {% endfor %} -
-
- - -
-
-
-
diff --git a/python/nav/web/templates/seeddb/list.html b/python/nav/web/templates/seeddb/list.html index d0c03dc572..d1ff5bc3ca 100644 --- a/python/nav/web/templates/seeddb/list.html +++ b/python/nav/web/templates/seeddb/list.html @@ -13,9 +13,7 @@ {% else %}
- {% if filter_form.no_crispy %} - {% include "seeddb/_filter_form.html" with attrs=filter_form.no_crispy %} - {% elif filter_form.attrs %} + {% if filter_form.attrs %} {% include 'custom_crispy_templates/flat_form.html' with form=filter_form %} {% else %} {% crispy filter_form %}