Skip to content
Snippets Groups Projects
Verified Commit 86a1276c authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Don't disable form fields because it is a mess to work with.

parent 0907a5c4
No related branches found
No related tags found
No related merge requests found
......@@ -25,9 +25,3 @@ class LessonSubstitutionForm(forms.ModelForm):
class Meta:
model = LessonSubstitution
fields = ['week', 'lesson_period', 'subject', 'teachers', 'room']
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['week'].disabled = True
self.fields['lesson_period'].disabled = True
......@@ -140,14 +140,8 @@ def edit_substitution(request: HttpRequest, id_: int, week: int) -> HttpResponse
lesson_substitution = LessonSubstitution.objects.filter(
week=week, lesson_period=lesson_period).first()
if lesson_substitution:
# Inject fields from URL as workaround for disabled form fields
# cf. https://stackoverflow.com/a/4664866/3035850
POST = request.POST.copy()
POST['week'] = week
POST['lesson_period'] = id_
edit_substitution_form = LessonSubstitutionForm(
POST or None, instance=lesson_substitution)
request.POST or None, instance=lesson_substitution)
else:
edit_substitution_form = LessonSubstitutionForm(
request.POST or None, initial={'week': week, 'lesson_period': lesson_period})
......
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