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

Fix actions for personal notes table to work only with correct items

(cherry picked from commit 4812fc8c)
parent 74de90da
No related branches found
No related tags found
Loading
Pipeline #24904 passed with warnings
......@@ -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
----------------------
......
......@@ -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")
......
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