Skip to content
Snippets Groups Projects
Verified Commit 5cad4d11 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Refactor forms.py

parent 5471dc7c
No related branches found
No related tags found
No related merge requests found
...@@ -5,16 +5,21 @@ from django.utils import timezone ...@@ -5,16 +5,21 @@ from django.utils import timezone
from .models import Menu from .models import Menu
current_year = timezone.datetime.now().year current_year = timezone.datetime.now().year
options_for_year = [(current_year, current_year), options_for_year = [(current_year, current_year), (current_year + 1, current_year + 1)]
(current_year + 1, current_year + 1)]
calendar_weeks = [(cw, cw) for cw in range(1, 53)]
class MenuUploadForm(forms.ModelForm): class MenuUploadForm(forms.ModelForm):
calendar_week = forms.ChoiceField(label="KW", choices=[(cw, cw) for cw in range(1, 53)]) calendar_week = forms.ChoiceField(choices=calendar_weeks)
year = forms.ChoiceField(label="Jahr", initial=timezone.datetime.now().year, year = forms.ChoiceField(
choices=options_for_year) initial=timezone.datetime.now().year, choices=options_for_year
)
pdf = forms.FileField(label="PDF-Datei", validators=[FileExtensionValidator(allowed_extensions=["pdf"])]) pdf = forms.FileField(
label="PDF-Datei",
validators=[FileExtensionValidator(allowed_extensions=["pdf"])],
)
class Meta: class Meta:
model = Menu model = Menu
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment