Skip to content

Commit

Permalink
Merge pull request #3196 from Uninett/uncrispify/DetentionProfileForm
Browse files Browse the repository at this point in the history
Uncrispify DetentionProfileForm
  • Loading branch information
stveit authored Nov 15, 2024
2 parents 9c879be + df681f4 commit 42c7d52
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 37 deletions.
81 changes: 46 additions & 35 deletions python/nav/web/arnold/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,11 @@

from IPy import IP
from django import forms
from crispy_forms.helper import FormHelper

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,
FlatFieldset,
FormCheckBox,
FormColumn,
FormDiv,
FormRow,
Expand Down Expand Up @@ -213,39 +210,53 @@ def __init__(self, *args, **kwargs):
did = self.data.get('detention_id') or self.initial.get('detention_id')
self.fields['justification'].choices = get_justifications(did)

self.helper = FormHelper()
self.helper.form_action = ''
self.helper.form_class = 'profileDetentionForm custom'
self.helper.layout = Layout(
'detention_id',
'title',
'description',
Fieldset(
'Obligatory',
Row(
Column('detention_type', css_class='medium-4'),
Column('justification', css_class='medium-4'),
Column('duration', css_class='medium-4'),
self.attrs = set_flat_form_attributes(
form_class='profileDetentionForm custom',
form_fields=[
self['detention_id'],
self['title'],
self['description'],
FlatFieldset(
'Obligatory',
fields=[
FormRow(
fields=[
FormColumn(
[self['detention_type']], css_classes='medium-4'
),
FormColumn(
[self['justification']], css_classes='medium-4'
),
FormColumn([self['duration']], css_classes='medium-4'),
]
),
FormDiv(fields=[self['qvlan']], css_classes='qvlanrow'),
],
css_class='secondary',
),
Div('qvlan', css_class='qvlanrow'),
css_class='secondary',
),
Fieldset(
'Extra options',
Row(
Column('keep_closed', css_class='medium-4'),
Column(
CheckBox('exponential', css_class='input-align'),
css_class='medium-4',
),
Div(css_class='medium-4 columns'),
FlatFieldset(
'Extra options',
fields=[
FormRow(
fields=[
FormColumn(
fields=[self['keep_closed']], css_classes='medium-4'
),
FormColumn(
fields=[FormCheckBox(self['exponential'])],
css_classes='medium-4',
),
FormDiv(css_classes='medium-4 columns'),
]
),
self['mail'],
self['active_on_vlans'],
],
css_class='secondary',
),
'mail',
'active_on_vlans',
css_class='secondary',
),
CheckBox('active', css_class='input-align'),
Submit('submit', 'Save'),
FormCheckBox(self['active']),
],
submit_field=SubmitField(value='Save'),
)


Expand Down
3 changes: 1 addition & 2 deletions python/nav/web/templates/arnold/edit_detention_profile.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% extends 'arnold/base.html' %}
{% load crispy_forms_tags %}

{% block content %}

Expand All @@ -11,7 +10,7 @@ <h4>Predefined Detention</h4>
<div class="large-8 column">
<div class="panel white">

{% crispy form %}
{% include 'custom_crispy_templates/flat_form.html' %}

{% if profile %}
<p>Last changed {{ profile.last_edited|date:'DATETIME_FORMAT' }}
Expand Down

0 comments on commit 42c7d52

Please sign in to comment.