From 3a148c49135036751c747c6b8593941c202e7b75 Mon Sep 17 00:00:00 2001 From: Ilona Podliashanyk Date: Thu, 26 Sep 2024 14:30:15 +0200 Subject: [PATCH 1/3] Uncrispyfy JustificationForm in arnold --- python/nav/web/arnold/forms.py | 22 +++++++++++++------ .../web/templates/arnold/justifications.html | 8 +++++-- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/python/nav/web/arnold/forms.py b/python/nav/web/arnold/forms.py index 74fcea3fd7..fe9de939d7 100644 --- a/python/nav/web/arnold/forms.py +++ b/python/nav/web/arnold/forms.py @@ -22,7 +22,12 @@ from crispy_forms_foundation.layout import Layout, Fieldset, Div, Row, Submit, Column from nav.util import is_valid_ip, is_valid_mac -from nav.web.crispyforms import CheckBox +from nav.web.crispyforms import ( + CheckBox, + FlatFieldset, + SubmitField, + set_flat_form_attributes, +) from nav.models.arnold import ( DETENTION_TYPE_CHOICES, STATUSES, @@ -50,12 +55,15 @@ def __init__(self, *args, **kwargs): submit_value = 'Save changes' fieldset_legend = 'Edit detention reason' - # Create helper for crispy layout - self.helper = FormHelper() - self.helper.form_action = 'arnold-justificatons' - self.helper.layout = Layout( - Fieldset(fieldset_legend, 'name', 'description', 'justificationid'), - Submit('submit', submit_value, css_class='small'), + self.attrs = set_flat_form_attributes( + form_action='arnold-justificatons', + form_fields=[ + FlatFieldset( + fieldset_legend, + fields=[self['name'], self['description'], self['justificationid']], + ) + ], + submit_field=SubmitField(value=submit_value, css_classes='small'), ) diff --git a/python/nav/web/templates/arnold/justifications.html b/python/nav/web/templates/arnold/justifications.html index 23b2db4c73..c99f25513b 100644 --- a/python/nav/web/templates/arnold/justifications.html +++ b/python/nav/web/templates/arnold/justifications.html @@ -50,8 +50,12 @@ {% comment %} Form for creating new justifications {% endcomment %} -
- {% crispy form %} +
+ {% if form.attrs %} + {% include 'custom_crispy_templates/flat_form.html' %} + {% else %} + {% crispy form %} + {% endif %}
From 3a0f0c09c90982c293f6da70335e213551c4f20b Mon Sep 17 00:00:00 2001 From: Ilona Podliashanyk Date: Thu, 26 Sep 2024 14:31:29 +0200 Subject: [PATCH 2/3] Remove crispy logic completely from justification form --- python/nav/web/templates/arnold/justifications.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/python/nav/web/templates/arnold/justifications.html b/python/nav/web/templates/arnold/justifications.html index c99f25513b..0cb92c57a3 100644 --- a/python/nav/web/templates/arnold/justifications.html +++ b/python/nav/web/templates/arnold/justifications.html @@ -1,5 +1,4 @@ {% extends "arnold/tabs.html" %} -{% load crispy_forms_tags %} {% block tabcontent %} @@ -54,7 +53,7 @@ {% if form.attrs %} {% include 'custom_crispy_templates/flat_form.html' %} {% else %} - {% crispy form %} + {{ form }} {% endif %} From 99151ddbd09c3a0198c7f0a18bd66e2f6ec96afd Mon Sep 17 00:00:00 2001 From: Ilona Podliashanyk Date: Mon, 30 Sep 2024 16:30:19 +0200 Subject: [PATCH 3/3] Fix indentation in html --- python/nav/web/templates/arnold/justifications.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/python/nav/web/templates/arnold/justifications.html b/python/nav/web/templates/arnold/justifications.html index 0cb92c57a3..a9bb20aff1 100644 --- a/python/nav/web/templates/arnold/justifications.html +++ b/python/nav/web/templates/arnold/justifications.html @@ -49,12 +49,12 @@ {% comment %} Form for creating new justifications {% endcomment %} -
- {% if form.attrs %} - {% include 'custom_crispy_templates/flat_form.html' %} - {% else %} - {{ form }} - {% endif %} +
+ {% if form.attrs %} + {% include 'custom_crispy_templates/flat_form.html' %} + {% else %} + {{ form }} + {% endif %}