Skip to content
Snippets Groups Projects
Unverified Commit 510b2d2a authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Work around limitation that model forms can only have editable fields.

parent fb4fd70b
No related branches found
No related tags found
No related merge requests found
......@@ -10,5 +10,18 @@ class LessonDocumentationForm(forms.ModelForm):
fields = ['topic', 'homework']
class PersonalNoteForm(forms.ModelForm):
class Meta:
model = PersonalNote
fields = ['person', 'absent', 'late', 'excused', 'remarks']
def __init__(self, *args, **kwargs):
super().__init__(*awrgs, **kwargs)
self.fields['person'].widget.attrs['readonly'] = True
def clean_person(self):
return self.instance.person
PersonalNoteFormSet = forms.modelformset_factory(
PersonalNote, fields=('person', 'absent', 'late', 'excused', 'remarks'))
PersonalNote, form=PersonalNoteForm)
......@@ -5,7 +5,7 @@ from biscuit.core.mixins import SchoolRelated
class PersonalNote(SchoolRelated):
person = models.ForeignKey('core.Person', models.CASCADE, editable=False)
person = models.ForeignKey('core.Person', models.CASCADE)
week = models.IntegerField()
lesson_period = models.ForeignKey('chronos.LessonPeriod', models.CASCADE)
......
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