Skip to content

Commit

Permalink
Merge pull request Uninett#3078 from Uninett/refactor/uncrispify-acti…
Browse files Browse the repository at this point in the history
…vity-interval-form-ipdevinfo

Uncrispify `ActivityIntervalForm` in ipdevinfo
  • Loading branch information
johannaengland authored Nov 7, 2024
2 parents 37c2b88 + 1f05e1f commit f74ddf0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
35 changes: 21 additions & 14 deletions python/nav/web/ipdevinfo/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@
#

from django import forms
from crispy_forms.helper import FormHelper
from crispy_forms_foundation.layout import Layout, Row, Column

from nav.models.manage import Sensor
from nav.web.crispyforms import (
FormColumn,
FormRow,
LabelSubmit,
SubmitField,
set_flat_form_attributes,
)
Expand Down Expand Up @@ -62,17 +60,26 @@ class ActivityIntervalForm(forms.Form):

def __init__(self, *args, **kwargs):
super(ActivityIntervalForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_tag = False
self.helper.layout = Layout(
Row(
Column('interval', css_class='small-4'),
Column(
LabelSubmit('submit', 'Recheck activity', css_class='postfix'),
css_class='small-8',
),
css_class='collapse',
)

self.attrs = set_flat_form_attributes(
form_fields=[
FormRow(
fields=[
FormColumn(fields=[self["interval"]], css_classes="small-4"),
FormColumn(
fields=[
SubmitField(
value="Recheck activity",
css_classes="postfix",
has_empty_label=True,
)
],
css_classes="small-8",
),
],
css_classes="collapse",
)
]
)


Expand Down
8 changes: 5 additions & 3 deletions python/nav/web/templates/ipdevinfo/modules.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{% load crispy_forms_tags %}

{% if port_view.perspective == 'swportactive' %}
<h5>
Activity based on CAM records since
Expand All @@ -9,7 +7,11 @@ <h5>
<div class="row">
<div class="medium-6 column">
<form id="switchport_activity_recheck" action="" method="get">
{% crispy activity_interval_form %}
{% if activity_interval_form.attrs %}
{% include 'custom_crispy_templates/_form_content.html' with form=activity_interval_form %}
{% else %}
{{ activity_interval_form }}
{% endif %}
</form>
</div>
<div class="medium-6 column">
Expand Down

0 comments on commit f74ddf0

Please sign in to comment.