Skip to content

Commit

Permalink
Remove crispy-forms from VlanFilterForm
Browse files Browse the repository at this point in the history
  • Loading branch information
johannaengland committed Sep 19, 2024
1 parent c5dfce2 commit 2c8d6a7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 25 deletions.
35 changes: 10 additions & 25 deletions python/nav/web/seeddb/page/vlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from nav.models.manage import Vlan, NetType, Organization, Usage

from nav.web.seeddb import SeeddbInfo, reverse_lazy
from nav.web.seeddb.forms import set_filter_form_attributes
from nav.web.seeddb.utils.list import render_list
from nav.web.seeddb.utils.edit import render_edit

Expand All @@ -42,34 +43,18 @@ class VlanInfo(SeeddbInfo):

class VlanFilterForm(forms.Form):
net_type = forms.ModelChoiceField(
NetType.objects.order_by('id').all(), required=False
NetType.objects.order_by('id').all(), required=False, label_suffix=""
)
organization = forms.ModelChoiceField(
Organization.objects.order_by('id').all(), required=False
Organization.objects.order_by('id').all(), required=False, label_suffix=""
)
usage = forms.ModelChoiceField(Usage.objects.order_by('id').all(), required=False)

def __init__(self, *args, **kwargs):
super(VlanFilterForm, self).__init__(*args, **kwargs)
col_class = 'medium-3'
self.helper = FormHelper()
self.helper.form_action = ''
self.helper.form_method = 'GET'
self.helper.form_class = 'custom'
self.helper.layout = Layout(
Fieldset(
'Filter vlans',
Row(
Column('net_type', css_class=col_class),
Column('organization', css_class=col_class),
Column('usage', css_class=col_class),
Column(
LabelSubmit('submit', 'Filter', css_class='postfix'),
css_class=col_class,
),
),
)
)
usage = forms.ModelChoiceField(
Usage.objects.order_by('id').all(), required=False, label_suffix=""
)
net_type.widget.attrs.update({"class": "select"})
organization.widget.attrs.update({"class": "select"})
usage.widget.attrs.update({"class": "select"})
no_crispy = set_filter_form_attributes('Filter vlans')


class VlanForm(forms.ModelForm):
Expand Down
24 changes: 24 additions & 0 deletions python/nav/web/templates/seeddb/_filter_form_vlans.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<form class="{{attrs.form_class }}" method="{{ attrs.method }}"{% if attrs.action %} action="{{ attrs.action }}"{% endif %}>
<fieldset>
<legend>{{ attrs.legend }}</legend>
<div class="row">
{% for field in filter_form %}
<div class="columns medium-3">
<div id="div_id_{{ field.name }}" class="ctrlHolder{% if field.errors %} error {% endif %}">
{{ field.label_tag }}
{{ field }}
{% for error in field.errors %}
<small id="error_{{ forloop.counter}}_id_{{ field.name }}" class="error">
{{ error }}
</small>
{% endfor %}
</div>
</div>
{% endfor %}
<div class="columns medium-3">
<label>&nbsp;</label>
<input type="submit" name="submit" value="{{ attrs.submit_value }}" class="submit button postfix" id="submit-id-submit">
</div>
</div>
</fieldset>
</form>

0 comments on commit 2c8d6a7

Please sign in to comment.