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

Fix missing form inputs in RoomFilterForm and NetboxTypeFilterForm in seeddb #3178

Merged
merged 4 commits into from
Nov 15, 2024
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
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):
# non-crispy 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
Loading