Skip to content

Commit

Permalink
Merge pull request Uninett#3132 from Uninett/uncrispify/L2TraceForm
Browse files Browse the repository at this point in the history
Uncrispify L2TraceForm
  • Loading branch information
stveit authored Nov 6, 2024
2 parents 3e28af0 + 9100b00 commit c3c1ff7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
34 changes: 18 additions & 16 deletions python/nav/web/l2trace/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@
# License along with NAV. If not, see <http://www.gnu.org/licenses/>.
#

from crispy_forms.helper import FormHelper
from crispy_forms_foundation.layout import Layout, Row, Column, Submit, Field
from nav.web.crispyforms import (
set_flat_form_attributes,
FormRow,
FormColumn,
SubmitField,
)
from django.core.exceptions import MultipleObjectsReturned
from django import forms

Expand All @@ -33,22 +37,20 @@ def __init__(self, *args, **kwargs):
super(L2TraceForm, self).__init__(*args, **kwargs)

placeholder_text = "Hostname or IP-address"
self.fields['host_from'].widget.attrs.update({"placeholder": placeholder_text})
self.fields['host_to'].widget.attrs.update({"placeholder": placeholder_text})

self.helper = FormHelper()
self.helper.form_action = ""
self.helper.form_method = 'GET'

self.helper.layout = Layout(
Row(
Column(
Field('host_from', placeholder=placeholder_text),
css_class='medium-6',
),
Column(
Field('host_to', placeholder=placeholder_text), css_class='medium-6'
self.attrs = set_flat_form_attributes(
form_method='get',
form_fields=[
FormRow(
fields=[
FormColumn(fields=[self['host_from']], css_classes='medium-6'),
FormColumn(fields=[self['host_to']], css_classes='medium-6'),
]
),
),
Submit('submit', 'Trace'),
SubmitField(value='Trace'),
],
)

def clean(self):
Expand Down
3 changes: 1 addition & 2 deletions python/nav/web/templates/l2trace/l2trace.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% extends "base.html" %}
{% load crispy_forms_tags %}
{% load tools %}


Expand All @@ -13,7 +12,7 @@
<div class="row">

<div class="column medium-6">
{% crispy form %}
{% include 'custom_crispy_templates/flat_form.html' %}
</div>

<div class="column medium-6">
Expand Down

0 comments on commit c3c1ff7

Please sign in to comment.