From 3926a9451b6d53ae4183da1de1343156f2204c6c Mon Sep 17 00:00:00 2001 From: Dominik George <nik@naturalnet.de> Date: Wed, 20 Nov 2019 20:49:10 +0100 Subject: [PATCH] Add overview page per student to printout. Advances #46. --- .../static/css/alsijil/full_register.css | 12 ++ .../alsijil/print/full_register.html | 122 +++++++++++++++++- biscuit/apps/alsijil/views.py | 2 +- 3 files changed, 134 insertions(+), 2 deletions(-) diff --git a/biscuit/apps/alsijil/static/css/alsijil/full_register.css b/biscuit/apps/alsijil/static/css/alsijil/full_register.css index a5fd2014b..38f146cdb 100644 --- a/biscuit/apps/alsijil/static/css/alsijil/full_register.css +++ b/biscuit/apps/alsijil/static/css/alsijil/full_register.css @@ -109,3 +109,15 @@ td.lesson-notes span.lesson-note-late { td.lesson-notes span.lesson-note-excused { color: #009933; } + +table.person-info { + border: none; +} + +table.person-info td.person-img { + text-align: center; +} + +table.person-info td.person-img img { + max-height: 30mm; +} diff --git a/biscuit/apps/alsijil/templates/alsijil/print/full_register.html b/biscuit/apps/alsijil/templates/alsijil/print/full_register.html index c8b656771..8485ea198 100644 --- a/biscuit/apps/alsijil/templates/alsijil/print/full_register.html +++ b/biscuit/apps/alsijil/templates/alsijil/print/full_register.html @@ -1,10 +1,12 @@ -{% load staticfiles i18n cropping data_helpers %} +{% load staticfiles i18n cropping data_helpers font_awesome week_helpers %} <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> + {% fa_css %} + <link rel="stylesheet" href="{% static 'css/alsijil/paper.css' %}" /> <link rel="stylesheet" @@ -120,6 +122,124 @@ </table> </section> + {% for person in persons %} + <section class="sheet padding-10mm"> + <h2>{% trans 'Personal overview' %}: {{ person.last_name }}, {{ person.first_name }}</h2> + + <h3>{% blocktrans %}Contact details{% endblocktrans %}</h3> + <table class="person-info"> + <tr> + <td rowspan="6" class="person-img"> + {% if person.photo %} + <img src="{% cropped_thumbnail person 'photo_cropping' max_size='300x400' %}" alt="{{ person.first_name }} {{ person.last_name }}" /> + {% else %} + <img src="{% static 'img/fallback.png' %}" alt="{{ person.first_name }} {{ person.last_name }}" /> + {% endif %} + </td> + <td>{% fa 'user' %}</td> + <td>{{ person.first_name }}</td> + <td>{{ person.additional_name }}</td> + <td>{{ person.last_name }}</td> + </tr> + <tr> + <td>{% fa 'venus-mars' %}</td> + <td colspan="3">{{ person.get_sex_display }}</td> + </tr> + <tr> + <td>{% fa 'fa-home' %}</td> + <td colspan="2">{{ person.street }} {{ person.housenumber }}</td> + <td colspan="2">{{ person.postal_code }} {{ person.place }}</td> + </tr> + <tr> + <td>{% fa 'phone-square' %}</td> + <td>{{ person.phone_number }}</td> + <td>{{ person.mobile_number }}</td> + </tr> + <tr> + <td>{% fa 'envelope' %}</td> + <td colspan="3">{{ person.email }}</td> + </tr> + <tr> + <td>{% fa 'gift' %}</td> + <td colspan="3">{{ person.date_of_birth|date }}</td> + </tr> + {% comment %} + <tr> + <td>{% fa 'graduation-cap' %}</td> + <td>Class</td> + <td>Teacher</td> + </tr> + {% endcomment %} + </table> + + {% if personal_note_filters %} + <h3>{% trans 'Statistics on remarks' %}</h3> + <table> + <thead> + <tr> + <th>{% trans 'Description' %}</th> + <th>{% trans 'Count' %}</th> + </tr> + </thead> + + <tbody> + {% for note_filter in personal_note_filters %} + <tr> + <td>{{ note_filter.description }}</td> + {% with "_personal_notes_with_"|add:note_filter.identifier as identifier %} + <td>{{ person|get_dict:identifier }}</td> + {% endwith %} + </tr> + {% endfor %} + </rbody> + </table> + {% endif %} + + <h3>{% trans 'Relevant personal notes' %}</h3> + <table> + <thead> + <tr> + <th>{% trans 'Date' %}</th> + <th>{% trans 'Pe.' %}</th> + <th>{% trans 'Subj.' %}</th> + <th>{% trans 'Te.' %}</th> + <th>{% trans 'Absent' %}</th> + <th>{% trans 'Tard.' %}</th> + <th>{% trans 'Remarks' %}</th> + </tr> + </thead> + + <tbody> + {% for note in person.personal_notes.all %} + {% if note.absent or note.late or note.remarks %} + {% period_to_date note.week note.lesson_period.period as note_date %} + <tr> + <td>{{ note_date }}</td> + <td>{{ note.lesson_period.period.period }}</td> + <td>{{ note.lesson_period.get_subject.abbrev }} </td> + <td>{{ note.lesson_period.get_teachers.first.short_name }}</td> + <td> + {% if note.absent %} + {% trans 'Yes' %} + {% if note.escused %} + ({% trans 'e' %}) + {% endif %} + {% endif %} + </td> + <td> + {% if note.late %} + {{ note.late }} + {% endif %} + </td> + <td>{{ note.remarks }}</td> + </tr> + {% endif %} + {% endfor %} + </tbody> + </table> + </section> + {% endfor %} + {% for week in weeks %} <section class="sheet padding-10mm smallprint"> <h2>{% trans 'Lesson documentation for calendar week' %} {{ week.week }}</h2> diff --git a/biscuit/apps/alsijil/views.py b/biscuit/apps/alsijil/views.py index 419bd6631..f0d4a3d29 100644 --- a/biscuit/apps/alsijil/views.py +++ b/biscuit/apps/alsijil/views.py @@ -201,7 +201,7 @@ def full_register_group(request: HttpRequest, id_: int) -> HttpResponse: personal_note_filters = PersonalNoteFilter.objects.all() for personal_note_filter in personal_note_filters: persons = persons.annotate( - **{'personal_notes_with_%s' % personal_note_filter.identifier: Count( + **{'_personal_notes_with_%s' % personal_note_filter.identifier: Count( 'personal_notes__remarks', filter=Q(personal_notes__remarks__iregex=personal_note_filter.regex) )} -- GitLab