diff --git a/schoolapps/aub/forms.py b/schoolapps/aub/forms.py index 57c53114360c61ffaaf2559217a9e573a10fb62c..9c19a43a09abfd4304d221c46cda733e1b7add36 100755 --- a/schoolapps/aub/forms.py +++ b/schoolapps/aub/forms.py @@ -3,6 +3,8 @@ from django.core.exceptions import ValidationError from django.utils import timezone from datetime import datetime from material import Layout, Row, Fieldset +from schoolapps import settings + class FilterAUBForm(forms.Form): timerangechoices = [('today','Heute'),('thisWeek','Diese Woche'), ('thisMonth','Dieser Monat')] @@ -20,13 +22,11 @@ class FilterAUBForm(forms.Form): cleaned_data = super().clean() class ApplyForAUBForm(forms.Form): - lessons = [('', ''), ('8:00', '1.'), ('8:45', '2.'), ('9:45', '3.'), ('10:35', '4.'), ('11:35', '5.'), - ('12:25', '6.'), ('13:15', '7.'), ('14:05', '8.'), ('14:50', '9.')] from_date = forms.DateField(label='Datum', input_formats=['%d.%m.%Y']) - from_lesson = forms.ChoiceField(label='Stunde', choices=lessons, required=False, widget=forms.Select(attrs = {'onchange' : 'set_time(this)'})) + from_lesson = forms.ChoiceField(label='Stunde', choices=settings.LESSONS, required=False, widget=forms.Select(attrs = {'onchange' : 'set_time(this)'})) from_time = forms.TimeField(label='Zeit', input_formats=['%H:%M'], initial='8:00', ) to_date = forms.DateField(label='Datum', input_formats=['%d.%m.%Y']) - to_lesson = forms.ChoiceField(label='Stunde', choices=lessons, required=False, widget=forms.Select(attrs = {'onchange' : 'set_time(this)'})) + to_lesson = forms.ChoiceField(label='Stunde', choices=settings.LESSONS, required=False, widget=forms.Select(attrs = {'onchange' : 'set_time(this)'})) to_time = forms.TimeField(label='Zeit', input_formats=['%H:%M'], initial='15:35') description = forms.CharField(label='Bitte begründen Sie Ihren Antrag.') @@ -62,34 +62,6 @@ class ApplyForAUBForm(forms.Form): raise ValidationError('Das Von-Datum liegt hinter dem Bis-Datum.') return True - # def clean_from_date(self): - # data = self.cleaned_data['from_date'] - # # if data < timezone.datetime.date(timezone.now()): - # # raise ValidationError('Die Befreiung kann nur zukünftig durchgeführt werden (Datumsfehler).') - # return data - # - # def clean_to_date(self): - # data = self.cleaned_data['to_date'] - # # if data < timezone.datetime.date(timezone.now()): - # # raise ValidationError('Die Befreiung kann nur zukünftig durchgeführt werden.') - # return data - # - # def clean_from_time(self): - # data = self.cleaned_data['from_time'] - # # print('Data:', type(data), 'Now:', type(timezone.datetime.time(timezone.now()))) - # - # # if data < timezone.datetime.time(timezone.now()): - # # raise ValidationError('Die Befreiung kann nur zukünftig durchgeführt werden (Zeitfehler).') - # - # return data - # - # def clean_to_time(self): - # data = self.cleaned_data['to_time'] - # - # # if data < timezone.datetime.time(timezone.now()): - # # raise ValidationError('Die Befreiung kann nur zukünftig durchgeführt werden.') - # return data - def clean_description(self): data = self.cleaned_data['description'] self.clean_from_to_date() diff --git a/schoolapps/schoolapps/settings.py b/schoolapps/schoolapps/settings.py index 34ffdfa4978a3d0e0bc262d86486be09ed242f45..1c5712452a827ec85d497077b390fa17feb89f3e 100755 --- a/schoolapps/schoolapps/settings.py +++ b/schoolapps/schoolapps/settings.py @@ -160,6 +160,8 @@ EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' # TIMETABLE TIMETABLE_WIDTH = 5 TIMETABLE_HEIGHT = 10 +LESSONS = [('8:00', '1.'), ('8:45', '2.'), ('9:45', '3.'), ('10:35', '4.'), ('11:35', '5.'), + ('12:25', '6.'), ('13:15', '7.'), ('14:05', '8.'), ('14:50', '9.')] ######## # LDAP #