From 12468ed9e0cb84b98ce0325bffaefadcca930a56 Mon Sep 17 00:00:00 2001
From: Dominik George <nik@naturalnet.de>
Date: Fri, 23 Aug 2019 09:51:52 +0200
Subject: [PATCH] Try getting to full names of persons.

---
 biscuit/apps/alsijil/forms.py                      | 11 +++++++----
 biscuit/apps/alsijil/templates/alsijil/lesson.html |  6 ++++--
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/biscuit/apps/alsijil/forms.py b/biscuit/apps/alsijil/forms.py
index bdfa7e7e4..200034c50 100644
--- a/biscuit/apps/alsijil/forms.py
+++ b/biscuit/apps/alsijil/forms.py
@@ -13,14 +13,17 @@ class LessonDocumentationForm(forms.ModelForm):
 class PersonalNoteForm(forms.ModelForm):
     class Meta:
         model = PersonalNote
-        fields = ['person', 'absent', 'late', 'excused', 'remarks']
+        fields = ['person__last_name', 'person__first_name', 'absent', 'late', 'excused', 'remarks']
 
     def __init__(self, *args, **kwargs):
         super().__init__(*args, **kwargs)
-        self.fields['person'].widget.attrs['readonly'] = True
+        self.fields['person__last_name'].widget.attrs['readonly'] = True
+        self.fields['person__first_name'].widget.attrs['readonly'] = True
 
-    def clean_person(self):
-      return self.instance.person
+    def clean_person__last_name(self):
+        return self.instance.person__last_name
+    def clean_person__first_name(self):
+        return self.instance.person__first_name
 
 
 PersonalNoteFormSet = forms.modelformset_factory(
diff --git a/biscuit/apps/alsijil/templates/alsijil/lesson.html b/biscuit/apps/alsijil/templates/alsijil/lesson.html
index 84ab4db61..c18a799d8 100644
--- a/biscuit/apps/alsijil/templates/alsijil/lesson.html
+++ b/biscuit/apps/alsijil/templates/alsijil/lesson.html
@@ -45,7 +45,8 @@
 
      <table class="table table-striped table-bordered table-hover table-condensed table-responsive w-100 d-block d-md-table">
       <tr>
-       <th>{% blocktrans %}Person{% endblocktrans %}</th>
+       <th>{% blocktrans %}Last name{% endblocktrans %}</th>
+       <th>{% blocktrans %}First name{% endblocktrans %}</th>
        <th>{% blocktrans %}Absent{% endblocktrans %}</th>
        <th>{% blocktrans %}Tardiness{% endblocktrans %}</th>
        <th>{% blocktrans %}Excused{% endblocktrans %}</th>
@@ -53,7 +54,8 @@
       </tr>
       {% for form in personal_note_formset %}
        <tr>
-        <td>{{ form.person }}</td>
+        <td>{{ form.person__last_name }}</td>
+        <td>{{ form.person__firstname }}</td>
         <td>{{ form.absent }}</td>
         <td>{{ form.late }}</td>
         <td>{{ form.excused }}</td>
-- 
GitLab