Skip to content

Commit

Permalink
Uncrispify NetboxFilterForm in seeddb
Browse files Browse the repository at this point in the history
  • Loading branch information
johannaengland committed Oct 3, 2024
1 parent c42a747 commit 5ff9cff
Showing 1 changed file with 48 additions and 19 deletions.
67 changes: 48 additions & 19 deletions python/nav/web/seeddb/page/netbox/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@
)

from nav.django.forms import HStoreField
from nav.web.crispyforms import LabelSubmit, NavButton
from nav.web.crispyforms import (
FlatFieldset,
FormColumn,
FormRow,
NavButton,
SubmitField,
set_flat_form_attributes,
)

from nav.models.manage import Room, Category, Organization, Netbox, ManagementProfile
from nav.web.seeddb.utils.edit import (
resolve_ip_and_sysname,
Expand Down Expand Up @@ -281,25 +289,46 @@ class NetboxFilterForm(forms.Form):

def __init__(self, *args, **kwargs):
super(NetboxFilterForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_action = ''
self.helper.form_method = 'GET'
self.helper.form_class = 'custom'

self.helper.layout = Layout(
Fieldset(
'Filter devices',
Row(
Column('category', css_class='medium-3'),
Column('room', css_class='medium-3'),
Column('organization', css_class='medium-3'),
Column('profile', css_class='medium-3'),
Column(
LabelSubmit('submit', 'Filter', css_class='postfix'),
css_class='medium-3',
),
),
)
common_class = "medium-3"

self.attrs = set_flat_form_attributes(
form_method="get",
form_class="custom",
form_fields=[
FlatFieldset(
"Filter devices",
fields=[
FormRow(
fields=[
FormColumn(
fields=[self["category"]], css_classes=common_class
),
FormColumn(
fields=[self["room"]], css_classes=common_class
),
FormColumn(
fields=[self["organization"]],
css_classes=common_class,
),
FormColumn(
fields=[self["profile"]], css_classes=common_class
),
FormColumn(
fields=[
SubmitField(
value="Filter",
css_classes="postfix",
has_empty_label=True,
)
],
css_classes=common_class,
),
]
)
],
)
],
)

@staticmethod
Expand Down

0 comments on commit 5ff9cff

Please sign in to comment.