Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncrispify MaintenanceTaskForm #3117

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions python/nav/web/maintenance/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
from datetime import date

from django import forms
from crispy_forms.helper import FormHelper
from crispy_forms_foundation.layout import Layout, Row, Column, Field
from nav.web.crispyforms import set_flat_form_attributes, FormRow, FormColumn
from nav.models.fields import INFINITY


Expand All @@ -29,20 +28,20 @@ class MaintenanceTaskForm(forms.Form):

def __init__(self, *args, **kwargs):
super(MaintenanceTaskForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_tag = False
self.helper.layout = Layout(
Row(
Column(
Field('start_time', css_class='datetimepicker'),
css_class="medium-6",
self.fields['start_time'].widget.attrs['class'] = 'datetimepicker'
self.fields['end_time'].widget.attrs['class'] = 'datetimepicker'

self.attrs = set_flat_form_attributes(
form_fields=[
FormRow(
fields=[
FormColumn(fields=[self['start_time']], css_classes='medium-6'),
FormColumn(fields=[self['end_time']], css_classes='medium-6'),
]
),
Column(
Field('end_time', css_class='datetimepicker'), css_class="medium-6"
),
),
'no_end_time',
'description',
self['no_end_time'],
self['description'],
]
)

# If end_time infinity, check no_end time and disable input
Expand Down
7 changes: 5 additions & 2 deletions python/nav/web/templates/maintenance/new_task.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% extends "maintenance/base.html" %}
{% load crispy_forms_tags %}

{% block base_header_additional_head %}
{{ block.super }}
Expand Down Expand Up @@ -36,7 +35,11 @@ <h4>{{ heading }}</h4>
<div class="large-4 columns">
<fieldset>
<legend>Details</legend>
{% crispy task_form %}
{% if task_form.attrs %}
{% include 'custom_crispy_templates/_form_content.html' with form=task_form %}
{% else %}
{{ task_form }}
{% endif %}
</fieldset>
</div>

Expand Down
Loading