12345678910111213141516171819202122232425262728 |
- import datetime
- from django import forms
- from .widgets import DatePickerWidget, SlotPickerWidget
- def get_hours():
- return [(x, datetime.time(x, 0)) for x in range(24)]
- 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)
- 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)
- class UpdateSlotsForm(forms.Form):
- slots = forms.Field(label='Slots')
- def __init__(self, *args, participant, **kwargs):
- super().__init__(*args, **kwargs)
- self.fields['slots'].widget = SlotPickerWidget(participant=participant)
|