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
from .models import Menu
current_year = timezone.datetime.now().year
options_for_year = [(current_year, current_year),
(current_year + 1, current_year + 1)]
options_for_year = [(current_year, current_year), (current_year + 1, current_year + 1)]
calendar_weeks = [(cw, cw) for cw in range(1, 53)]
class MenuUploadForm(forms.ModelForm):
calendar_week = forms.ChoiceField(label="KW", choices=[(cw, cw) for cw in range(1, 53)])
year = forms.ChoiceField(label="Jahr", initial=timezone.datetime.now().year,
choices=options_for_year)
calendar_week = forms.ChoiceField(choices=calendar_weeks)
year = forms.ChoiceField(
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:
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