diff --git a/aleksis/apps/alsijil/checks.py b/aleksis/apps/alsijil/checks.py index a440f52da0888a3a97f752affd038c0fff583244..437b616d48bb12c25eec9fb5bcf91cc3b52cb5f0 100644 --- a/aleksis/apps/alsijil/checks.py +++ b/aleksis/apps/alsijil/checks.py @@ -46,12 +46,12 @@ class NoParticipationStatusesPersonalNotesInCancelledLessonsDataCheck(DataCheck) @classmethod def check_data(cls): - from .models import NewPersonalNote, ParticipationStatus + from .models import PersonalNote, ParticipationStatus participation_statuses = ParticipationStatus.objects.filter( related_documentation__amends__in=LessonEvent.objects.filter(cancelled=True) ) - personal_notes = NewPersonalNote.objects.filter( + personal_notes = PersonalNote.objects.filter( documentation__amends__in=LessonEvent.objects.filter(cancelled=True) ) diff --git a/aleksis/apps/alsijil/migrations/0026_rename_newpersonalnote_personalnote.py b/aleksis/apps/alsijil/migrations/0026_rename_newpersonalnote_personalnote.py new file mode 100644 index 0000000000000000000000000000000000000000..0f157a79454bb7d9aaf9645c1b6084a4da0f8807 --- /dev/null +++ b/aleksis/apps/alsijil/migrations/0026_rename_newpersonalnote_personalnote.py @@ -0,0 +1,18 @@ +# Generated by Django 5.1.3 on 2024-11-30 12:35 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("alsijil", "0025_remove_old_models"), + ("core", "0068_calendar_event_amends_unique_constraints"), + ] + + operations = [ + migrations.RenameModel( + old_name="NewPersonalNote", + new_name="PersonalNote", + ), + ] diff --git a/aleksis/apps/alsijil/models.py b/aleksis/apps/alsijil/models.py index 9e2d50dead158fcf5f408ffdff59327cda942a01..28404cb6add123890a70f3930f6ed88b302b7a0d 100644 --- a/aleksis/apps/alsijil/models.py +++ b/aleksis/apps/alsijil/models.py @@ -497,7 +497,7 @@ class ParticipationStatus(CalendarEvent): ] -class NewPersonalNote(ExtensibleModel): +class PersonalNote(ExtensibleModel): person = models.ForeignKey( "core.Person", models.CASCADE, related_name="new_personal_notes", verbose_name=_("Person") ) diff --git a/aleksis/apps/alsijil/schema/__init__.py b/aleksis/apps/alsijil/schema/__init__.py index 604cda6cd229533086533d855563a892f440d572..5e32ec67a655c3bdb8b20ec98c08b57b7577cb28 100644 --- a/aleksis/apps/alsijil/schema/__init__.py +++ b/aleksis/apps/alsijil/schema/__init__.py @@ -22,7 +22,7 @@ from aleksis.core.util.core_helpers import ( ) from ..model_extensions import annotate_person_statistics_for_school_term -from ..models import Documentation, ExtraMark, NewPersonalNote, ParticipationStatus +from ..models import Documentation, ExtraMark, PersonalNote, ParticipationStatus from .absences import ( AbsencesForPersonsCreateMutation, ) @@ -324,7 +324,7 @@ class Query(graphene.ObjectType): return [] school_term = get_active_school_term(info.context) return graphene_django_optimizer.query( - NewPersonalNote.objects.filter( + PersonalNote.objects.filter( person=person, documentation__in=Documentation.objects.filter( datetime_start__date__gte=school_term.date_start, diff --git a/aleksis/apps/alsijil/schema/participation_status.py b/aleksis/apps/alsijil/schema/participation_status.py index bb0e24e0564ab5f87a3fe1a25c85f4d8c5766241..98e11ef70542dacb87ca320baba7333af55634bf 100644 --- a/aleksis/apps/alsijil/schema/participation_status.py +++ b/aleksis/apps/alsijil/schema/participation_status.py @@ -7,7 +7,7 @@ import graphene from graphene_django import DjangoObjectType from reversion import create_revision, set_comment, set_user -from aleksis.apps.alsijil.models import NewPersonalNote, ParticipationStatus +from aleksis.apps.alsijil.models import PersonalNote, ParticipationStatus from aleksis.apps.alsijil.schema.personal_note import PersonalNoteType from aleksis.apps.kolego.models import Absence from aleksis.apps.kolego.schema.absence import AbsenceType @@ -47,7 +47,7 @@ class ParticipationStatusType( for p in root._prefetched_documentation.personal_notes.all() if p.person_id == root.person_id and p.extra_mark ] - return NewPersonalNote.objects.filter( + return PersonalNote.objects.filter( person=root.person, documentation=root.related_documentation, extra_mark__isnull=False, @@ -61,7 +61,7 @@ class ParticipationStatusType( for p in root._prefetched_documentation.personal_notes.all() if p.person_id == root.person_id and p.note ] - return NewPersonalNote.objects.filter( + return PersonalNote.objects.filter( person=root.person, documentation=root.related_documentation, note__isnull=False, diff --git a/aleksis/apps/alsijil/schema/personal_note.py b/aleksis/apps/alsijil/schema/personal_note.py index 7a9e20edadc426c7bf6d846b002c8d04ac9d7967..a30e96edc2f6b2da9ec426bb6392a61ffff40c02 100644 --- a/aleksis/apps/alsijil/schema/personal_note.py +++ b/aleksis/apps/alsijil/schema/personal_note.py @@ -1,6 +1,6 @@ from graphene_django import DjangoObjectType -from aleksis.apps.alsijil.models import NewPersonalNote +from aleksis.apps.alsijil.models import PersonalNote from aleksis.core.schema.base import ( BaseBatchCreateMutation, BaseBatchDeleteMutation, @@ -18,7 +18,7 @@ class PersonalNoteType( DjangoObjectType, ): class Meta: - model = NewPersonalNote + model = PersonalNote fields = ( "id", "note", @@ -29,7 +29,7 @@ class PersonalNoteType( class PersonalNoteBatchCreateMutation(BaseBatchCreateMutation): class Meta: - model = NewPersonalNote + model = PersonalNote type_name = "BatchCreatePersonalNoteInput" return_field_name = "personalNotes" fields = ("note", "extra_mark", "documentation", "person") @@ -38,7 +38,7 @@ class PersonalNoteBatchCreateMutation(BaseBatchCreateMutation): class PersonalNoteBatchPatchMutation(BaseBatchPatchMutation): class Meta: - model = NewPersonalNote + model = PersonalNote type_name = "BatchPatchPersonalNoteInput" return_field_name = "personalNotes" fields = ("id", "note", "extra_mark", "documentation", "person") @@ -47,5 +47,5 @@ class PersonalNoteBatchPatchMutation(BaseBatchPatchMutation): class PersonalNoteBatchDeleteMutation(BaseBatchDeleteMutation): class Meta: - model = NewPersonalNote + model = PersonalNote permissions = ("alsijil.edit_personal_note_rule",) diff --git a/aleksis/apps/alsijil/util/predicates.py b/aleksis/apps/alsijil/util/predicates.py index 7177034281562b2aae4d9983f70def95f4a1c75a..795999c03c718477862b1d522867b71e7344d55d 100644 --- a/aleksis/apps/alsijil/util/predicates.py +++ b/aleksis/apps/alsijil/util/predicates.py @@ -12,7 +12,7 @@ from aleksis.core.models import Group, Person from aleksis.core.util.core_helpers import get_site_preferences from aleksis.core.util.predicates import check_object_permission -from ..models import Documentation, NewPersonalNote +from ..models import Documentation, PersonalNote @predicate @@ -308,13 +308,13 @@ def can_edit_participation_status(user: User, obj: Documentation): @predicate -def is_in_allowed_time_range(user: User, obj: Union[Documentation, NewPersonalNote]): +def is_in_allowed_time_range(user: User, obj: Union[Documentation, PersonalNote]): """Predicate for documentations or new personal notes with linked documentation. Predicate which checks if the given documentation or the documentation linked - to the given NewPersonalNote is in the allowed time range for editing. + to the given PersonalNote is in the allowed time range for editing. """ - if isinstance(obj, NewPersonalNote): + if isinstance(obj, PersonalNote): obj = obj.documentation if obj and ( get_site_preferences()["alsijil__allow_edit_future_documentations"] == "all" @@ -340,7 +340,7 @@ def is_in_allowed_time_range_for_participation_status(user: User, obj: Documenta @predicate -def can_view_personal_note(user: User, obj: NewPersonalNote): +def can_view_personal_note(user: User, obj: PersonalNote): """Predicate which checks if the user is allowed to view a personal note.""" if obj.documentation: if is_documentation_teacher(user, obj.documentation): @@ -355,7 +355,7 @@ def can_view_personal_note(user: User, obj: NewPersonalNote): @predicate -def can_edit_personal_note(user: User, obj: NewPersonalNote): +def can_edit_personal_note(user: User, obj: PersonalNote): """Predicate which checks if the user is allowed to edit a personal note.""" if obj.documentation: if is_documentation_teacher(user, obj.documentation):