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

Merge branch '89-only-show-group-members-in-full-register-printout-too' into 'master'

Resolve "[Full register] Only show personal notes of group members"

Closes #89

See merge request !70
parents 8fa024da 1229e2ec
No related branches found
No related tags found
1 merge request!70Resolve "[Full register] Only show personal notes of group members"
Pipeline #3195 passed
# Generated by Django 3.0.8 on 2020-07-22 17:29
from django.db import migrations, models
def add_groups(apps, schema_editor):
PersonalNote = apps.get_model("alsijil", "PersonalNote")
db_alias = schema_editor.connection.alias
for personal_note in PersonalNote.objects.using(db_alias).all():
groups = list(personal_note.person.member_of.using(db_alias).all())
personal_note.groups_of_person.set(groups)
personal_note.save()
class Migration(migrations.Migration):
dependencies = [
("core", "0003_drop_image_cropping"),
("alsijil", "0002_excuse_type"),
]
operations = [
migrations.AddField(
model_name="personalnote",
name="groups_of_person",
field=models.ManyToManyField(
related_name="_personalnote_groups_of_person_+", to="core.Group"
),
),
migrations.RunPython(add_groups),
]
...@@ -42,6 +42,7 @@ class PersonalNote(ExtensibleModel): ...@@ -42,6 +42,7 @@ class PersonalNote(ExtensibleModel):
person = models.ForeignKey( person = models.ForeignKey(
"core.Person", models.CASCADE, related_name="personal_notes" "core.Person", models.CASCADE, related_name="personal_notes"
) )
groups_of_person = models.ManyToManyField("core.Group", related_name="+")
week = models.IntegerField() week = models.IntegerField()
lesson_period = models.ForeignKey( lesson_period = models.ForeignKey(
......
...@@ -412,34 +412,36 @@ ...@@ -412,34 +412,36 @@
<td class="lesson-notes"> <td class="lesson-notes">
{{ documentations.0.group_note }} {{ documentations.0.group_note }}
{% for note in notes %} {% for note in notes %}
{% if note.absent %} {% if group in note.groups_of_person.all %}
<span class="lesson-note-absent"> {% if note.absent %}
{{ note.person.last_name }}, {{ note.person.first_name|slice:"0:1" }}. <span class="lesson-note-absent">
{% if note.excused %} {{ note.person.last_name }}, {{ note.person.first_name|slice:"0:1" }}.
<span class="lesson-note-excused"> {% if note.excused %}
{% if note.excuse_type %} <span class="lesson-note-excused">
({{ note.excuse_type.short_name }}) {% if note.excuse_type %}
{% else %} ({{ note.excuse_type.short_name }})
({% trans 'e' %}) {% else %}
{% endif %} ({% trans 'e' %})
</span> {% endif %}
{% endif %} </span>
{% endif %}
</span> </span>
{% endif %} {% endif %}
{% if note.late %} {% if note.late %}
<span class="lesson-note-late"> <span class="lesson-note-late">
{{ note.person.last_name }}, {{ note.person.first_name|slice:"0:1" }}. {{ note.person.last_name }}, {{ note.person.first_name|slice:"0:1" }}.
({{ note.late }}′) ({{ note.late }}′)
{% if note.excused %} {% if note.excused %}
<span class="lesson-note-excused"> <span class="lesson-note-excused">
{% if note.excuse_type %} {% if note.excuse_type %}
({{ note.excuse_type.short_name }}) ({{ note.excuse_type.short_name }})
{% else %} {% else %}
({% trans 'e' %}) ({% trans 'e' %})
{% endif %} {% endif %}
</span> </span>
{% endif %} {% endif %}
</span> </span>
{% endif %}
{% endif %} {% endif %}
{% for extra_mark in note.extra_marks.all %} {% for extra_mark in note.extra_marks.all %}
<span> <span>
......
...@@ -360,7 +360,10 @@ def full_register_group(request: HttpRequest, id_: int) -> HttpResponse: ...@@ -360,7 +360,10 @@ def full_register_group(request: HttpRequest, id_: int) -> HttpResponse:
(lesson_period, documentations, notes, substitution) (lesson_period, documentations, notes, substitution)
) )
persons = group.members.annotate( persons = Person.objects.filter(
personal_notes__groups_of_person=group,
personal_notes__lesson_period__lesson__validity__school_term=current_school_term,
).annotate(
absences_count=Count( absences_count=Count(
"personal_notes__absent", "personal_notes__absent",
filter=Q( filter=Q(
......
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