From 5cad4d11fc1497f5ae601afe5ca669a22bbb0f8c Mon Sep 17 00:00:00 2001
From: Jonathan Weth <git@jonathanweth.de>
Date: Thu, 16 Jan 2020 19:29:36 +0100
Subject: [PATCH] Refactor forms.py

---
 aleksis/apps/mensa/forms.py | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/aleksis/apps/mensa/forms.py b/aleksis/apps/mensa/forms.py
index 7e6b47d..1a3afd6 100644
--- a/aleksis/apps/mensa/forms.py
+++ b/aleksis/apps/mensa/forms.py
@@ -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
-- 
GitLab