diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 056214adae1c79e4f121de6d59397cc0dfcb1a24..b1348da88bfe340e7947af0eb1ebc23033c901c2 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,6 +14,8 @@ Fixed * The lesson documentations tab was displayed on overviews for persons who are not teachers. * Teachers weren't able to edit personal notes of their students in the person overview. +* The actions to mark absences as excused in the personal notes table also marked personal notes as excused which are not absences. +* The delete action in the personal notes table really deleted the items instead of just resetting them to default values. `2.0rc3`_ - 2021-07-20 ---------------------- diff --git a/aleksis/apps/alsijil/actions.py b/aleksis/apps/alsijil/actions.py index 5e7da3a3207965fc8ddb176fef5581784674885e..2d42d6134e8bd7e617f918ce864ad0a479761a3a 100644 --- a/aleksis/apps/alsijil/actions.py +++ b/aleksis/apps/alsijil/actions.py @@ -7,18 +7,19 @@ from django.template.loader import get_template from django.urls import reverse from django.utils.translation import gettext_lazy as _ +from aleksis.apps.alsijil.models import PersonalNote from aleksis.core.models import Notification def mark_as_excused(modeladmin, request, queryset): - queryset.update(excused=True, excuse_type=None) + queryset.filter(absent=True).update(excused=True, excuse_type=None) mark_as_excused.short_description = _("Mark as excused") def mark_as_unexcused(modeladmin, request, queryset): - queryset.update(excused=False, excuse_type=None) + queryset.filter(absent=True).update(excused=False, excuse_type=None) mark_as_unexcused.short_description = _("Mark as unexcused") @@ -26,7 +27,7 @@ mark_as_unexcused.short_description = _("Mark as unexcused") def mark_as_excuse_type_generator(excuse_type) -> Callable: def mark_as_excuse_type(modeladmin, request, queryset): - queryset.update(excused=True, excuse_type=excuse_type) + queryset.filter(absent=True).update(excused=True, excuse_type=excuse_type) mark_as_excuse_type.short_description = _(f"Mark as {excuse_type.name}") mark_as_excuse_type.__name__ = f"mark_as_excuse_type_{excuse_type.short_name}" @@ -35,7 +36,11 @@ def mark_as_excuse_type_generator(excuse_type) -> Callable: def delete_personal_note(modeladmin, request, queryset): - queryset.delete() + notes = [] + for personal_note in queryset: + personal_note.reset_values() + notes.append(personal_note) + PersonalNote.objects.bulk_update(notes) delete_personal_note.short_description = _("Delete")