|
@@ -1,6 +1,7 @@
|
|
|
import datetime
|
|
|
|
|
|
from django import forms
|
|
|
+from django.utils.translation import gettext_lazy as _
|
|
|
|
|
|
from .widgets import DatePickerWidget, SlotPickerWidget
|
|
|
|
|
@@ -10,11 +11,11 @@ def get_interval():
|
|
|
return [(x, datetime.timedelta(minutes=x)) for x in [15, 30, 60]]
|
|
|
|
|
|
class CreateEventForm(forms.Form):
|
|
|
- event_name = forms.CharField(label='Event name', max_length=100)
|
|
|
- event_date = forms.Field(label='Event date', widget=DatePickerWidget)
|
|
|
- start_time = forms.ChoiceField(label='Start time', initial=9, choices=get_hours)
|
|
|
- end_time = forms.ChoiceField(label='End time', initial=20, choices=get_hours)
|
|
|
- slot_interval = forms.ChoiceField(label='Time slot interval', initial=15, choices=get_interval)
|
|
|
+ event_name = forms.CharField(label=_('Event name'), max_length=100)
|
|
|
+ event_date = forms.Field(label=_('Event date'), widget=DatePickerWidget)
|
|
|
+ start_time = forms.ChoiceField(label=_('Start time'), initial=9, choices=get_hours)
|
|
|
+ end_time = forms.ChoiceField(label=_('End time'), initial=20, choices=get_hours)
|
|
|
+ slot_interval = forms.ChoiceField(label=_('Time slot interval'), initial=15, choices=get_interval)
|
|
|
|
|
|
def clean(self) -> dict:
|
|
|
cleaned_data = super().clean()
|
|
@@ -22,16 +23,16 @@ class CreateEventForm(forms.Form):
|
|
|
return cleaned_data
|
|
|
|
|
|
if cleaned_data['start_time'] == cleaned_data['end_time']:
|
|
|
- self.add_error('start_time', 'Start time must be different from end time')
|
|
|
+ self.add_error('start_time', _('Start time must be different from end time'))
|
|
|
|
|
|
return cleaned_data
|
|
|
|
|
|
class LoginForm(forms.Form):
|
|
|
- username = forms.CharField(label='Username', max_length=100)
|
|
|
- password = forms.CharField(label='Password', max_length=100, widget=forms.PasswordInput, required=False)
|
|
|
+ username = forms.CharField(label=_('Username'), max_length=100)
|
|
|
+ password = forms.CharField(label=_('Password'), max_length=100, widget=forms.PasswordInput, required=False)
|
|
|
|
|
|
class UpdateSlotsForm(forms.Form):
|
|
|
- slots = forms.Field(label='Slots')
|
|
|
+ slots = forms.Field(label=_('Slots'))
|
|
|
|
|
|
def __init__(self, *args, participant, **kwargs):
|
|
|
super().__init__(*args, **kwargs)
|