Skip to content

Commit

Permalink
Merge pull request Uninett#3178 from Uninett/fix-missing-filter-input…
Browse files Browse the repository at this point in the history
…s-in-seeddb

Fix missing form inputs in RoomFilterForm and NetboxTypeFilterForm in seeddb
  • Loading branch information
podliashanyk authored Nov 15, 2024
2 parents 31643d8 + 111e075 commit 901433d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
18 changes: 14 additions & 4 deletions python/nav/web/seeddb/forms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def cut_branch(field, klass, pk):
# helpers


def get_single_layout(heading, row):
def get_single_layout(heading, filter_field):
"""Get default layout for a single filter"""
return set_flat_form_attributes(
form_class="custom",
Expand All @@ -140,7 +140,7 @@ def get_single_layout(heading, row):
fields=[
FormRow(
fields=[
FormColumn(fields=[row], css_classes="medium-8"),
FormColumn(fields=[filter_field], css_classes="medium-8"),
FormColumn(
fields=[
SubmitField(
Expand Down Expand Up @@ -169,7 +169,12 @@ class RoomFilterForm(forms.Form):
Location.objects.order_by('id').all(), required=False
)
location.widget.attrs.update({"class": "select"})
attrs = get_single_layout(heading="Filter rooms", row=[location])

def __init__(self, *args, **kwargs):
super(RoomFilterForm, self).__init__(*args, **kwargs)
self.attrs = get_single_layout(
heading="Filter rooms", filter_field=self["location"]
)


class RoomForm(forms.ModelForm):
Expand Down Expand Up @@ -285,7 +290,12 @@ class NetboxTypeFilterForm(forms.Form):
"""Form for filtering a netbox type by vendor"""

vendor = forms.ModelChoiceField(Vendor.objects.order_by('id').all(), required=False)
attrs = get_single_layout(heading="Filter types", row=[vendor])

def __init__(self, *args, **kwargs):
super(NetboxTypeFilterForm, self).__init__(*args, **kwargs)
self.attrs = get_single_layout(
heading="Filter types", filter_field=self["vendor"]
)


class NetboxTypeForm(forms.ModelForm):
Expand Down
2 changes: 1 addition & 1 deletion python/nav/web/seeddb/page/management_profile/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, *args, **kwargs):
super(ManagementProfileFilterForm, self).__init__(*args, **kwargs)

self.attrs = get_single_layout(
heading="Filter connection profiles", row=self["protocol"]
heading="Filter connection profiles", filter_field=self["protocol"]
)


Expand Down

0 comments on commit 901433d

Please sign in to comment.