Skip to content

Commit

Permalink
Use new uncrispified templates in filtering seedDB
Browse files Browse the repository at this point in the history
  • Loading branch information
johannaengland committed Oct 9, 2024
1 parent d6e9b83 commit b4db6dc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 52 deletions.
35 changes: 10 additions & 25 deletions python/nav/web/seeddb/forms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
24 changes: 0 additions & 24 deletions python/nav/web/templates/seeddb/_filter_form.html

This file was deleted.

4 changes: 1 addition & 3 deletions python/nav/web/templates/seeddb/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
{% else %}
<div class="row">
<div class="medium-6 column">
{% 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 %}
Expand Down

0 comments on commit b4db6dc

Please sign in to comment.