Skip to content
Snippets Groups Projects
Verified Commit 1229e2ec authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Show only personal notes of (historical) group members

Archive groups of a person for every personal note to check against it
to decide what data should be displayed in full register print out
parent 9c025c60
No related branches found
No related tags found
1 merge request!70Resolve "[Full register] Only show personal notes of group members"
Pipeline #3119 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(
......
...@@ -397,7 +397,7 @@ ...@@ -397,7 +397,7 @@
<td class="lesson-homework">{{ documentations.0.homework }}</td> <td class="lesson-homework">{{ documentations.0.homework }}</td>
<td class="lesson-notes"> <td class="lesson-notes">
{% for note in notes %} {% for note in notes %}
{% if note.person in group.members.all %} {% if group in note.groups_of_person.all %}
{% if note.absent %} {% if note.absent %}
<span class="lesson-note-absent"> <span class="lesson-note-absent">
{{ note.person.last_name }}, {{ note.person.first_name|slice:"0:1" }}. {{ note.person.last_name }}, {{ note.person.first_name|slice:"0:1" }}.
......
...@@ -334,7 +334,10 @@ def full_register_group(request: HttpRequest, id_: int) -> HttpResponse: ...@@ -334,7 +334,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", filter=Q(personal_notes__absent=True) "personal_notes__absent", filter=Q(personal_notes__absent=True)
), ),
......
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