Skip to content
Snippets Groups Projects
Commit 3824ab68 authored by Lukas Weichelt's avatar Lukas Weichelt
Browse files

Rename NewPersonalNote to PersonalNote

parent a1aedec2
Branches merge
No related tags found
1 merge request!441Resolve "Rename NewPersonalNote to PersonalNote"
Pipeline #194012 failed
......@@ -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)
)
......
# 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",
),
]
......@@ -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")
)
......
......@@ -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,
......
......@@ -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,
......
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",)
......@@ -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):
......
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