2023-08-05 13:18:20 +02:00
|
|
|
from django import forms
|
|
|
|
from crispy_forms.helper import FormHelper
|
|
|
|
from crispy_forms.layout import Layout, Submit, Div
|
|
|
|
from crispy_bootstrap5.bootstrap5 import FloatingField
|
2023-08-05 08:43:48 +02:00
|
|
|
|
|
|
|
from .models import Ticket
|
|
|
|
|
|
|
|
|
2023-08-06 04:53:09 +02:00
|
|
|
class TicketForm(forms.ModelForm):
|
2023-08-05 13:18:20 +02:00
|
|
|
|
2023-08-05 08:43:48 +02:00
|
|
|
class Meta:
|
|
|
|
model = Ticket
|
2023-08-09 09:53:20 +02:00
|
|
|
fields = ['number', 'attempts', 'platform', 'note']
|
2023-08-05 13:18:20 +02:00
|
|
|
widgets = {
|
|
|
|
'platform': forms.RadioSelect()
|
|
|
|
}
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
2023-08-06 04:53:09 +02:00
|
|
|
super(TicketForm, self).__init__(*args, **kwargs)
|
2023-08-05 13:18:20 +02:00
|
|
|
self.helper = FormHelper(self)
|
|
|
|
# self.helper.attrs = {"novalidate": ''}
|
|
|
|
|
|
|
|
self.helper.layout = Layout(
|
2023-08-09 09:53:20 +02:00
|
|
|
Div(
|
|
|
|
FloatingField('number', 'attempts'),
|
|
|
|
'platform',
|
|
|
|
css_class='col-lg-2'
|
|
|
|
),
|
2023-08-06 04:53:09 +02:00
|
|
|
Div('note', css_class='col-lg-6'),
|
|
|
|
Submit('submit', 'Save', css_class='btn btn-primary'),
|
2023-08-05 13:18:20 +02:00
|
|
|
)
|