Skip to content

Commit

Permalink
Uncrispify MessageForm
Browse files Browse the repository at this point in the history
  • Loading branch information
stveit committed Oct 9, 2024
1 parent 98ae393 commit a7a6706
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions python/nav/web/messages/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"""Form models for Messages"""

from django.forms import ModelForm
from crispy_forms.helper import FormHelper
from crispy_forms_foundation.layout import Submit
from nav.web.crispyforms import set_flat_form_attributes, SubmitField, FlatFieldset

from nav.models.msgmaint import Message
from nav.models.msgmaint import MessageToMaintenanceTask
Expand All @@ -28,11 +27,22 @@ class MessageForm(ModelForm):

def __init__(self, *args, **kwargs):
super(MessageForm, self).__init__(*args, **kwargs)

self.helper = FormHelper()
self.helper.form_action = ""
self.helper.form_method = 'POST'
self.helper.add_input(Submit('submit', 'Save message', css_class='small'))
self.attrs = set_flat_form_attributes(
form_fields=[
FlatFieldset(
legend='',
fields=[
self['title'],
self['description'],
self['tech_description'],
self['publish_start'],
self['publish_end'],
self['maintenance_tasks'],
],
),
],
submit_field=SubmitField(value='Save message', css_classes='small'),
)

# Since the m2m uses through, we need to fetch initial data manually
initials = []
Expand Down

0 comments on commit a7a6706

Please sign in to comment.