Skip to content

Commit

Permalink
Merge pull request #3039 from podliashanyk/uncrispyfy-arnold-justific…
Browse files Browse the repository at this point in the history
…ation-form

Uncrispyfy JustificationForm in arnold
  • Loading branch information
podliashanyk authored Oct 1, 2024
2 parents c5aed1f + 99151dd commit 9eeeb3c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
22 changes: 15 additions & 7 deletions python/nav/web/arnold/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'),
)


Expand Down
7 changes: 5 additions & 2 deletions python/nav/web/templates/arnold/justifications.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% extends "arnold/tabs.html" %}
{% load crispy_forms_tags %}

{% block tabcontent %}

Expand Down Expand Up @@ -51,7 +50,11 @@

{% comment %} Form for creating new justifications {% endcomment %}
<div class="medium-6 column">
{% crispy form %}
{% if form.attrs %}
{% include 'custom_crispy_templates/flat_form.html' %}
{% else %}
{{ form }}
{% endif %}
</div>

</div>
Expand Down

0 comments on commit 9eeeb3c

Please sign in to comment.