Skip to content
Snippets Groups Projects
Commit ca799cae authored by magicfelix's avatar magicfelix
Browse files

Rename references on lesson_event to amends

parent 2013968a
No related branches found
No related tags found
1 merge request!350Resolve "Add simple course book list"
Pipeline #181002 failed
......@@ -37,7 +37,7 @@ query documentationsForCoursebook(
id
name
}
lessonEvent {
amends {
id
amends {
id
......
......@@ -78,13 +78,13 @@ export default {
},
methods: {
updateStatus() {
if (this.documentation?.lessonEvent.cancelled) {
if (this.documentation?.amends.cancelled) {
this.currentStatusName = "cancelled";
} else if (this.documentation.topic) {
this.currentStatusName = "available";
} else if (DateTime.now() > this.documentationDateTimeEnd) {
this.currentStatusName = "missing";
} else if (this.documentation?.lessonEvent.amends) {
} else if (this.documentation?.amends.amends) {
this.currentStatusName = "substitution";
} else if (
DateTime.now() > this.documentationDateTimeStart &&
......
......@@ -41,11 +41,11 @@ import PersonChip from "aleksis.core/components/person/PersonChip.vue";
/>
<subject-chip
v-if="
documentation?.lessonEvent?.amends?.subject &&
documentation.lessonEvent.amends.subject.id !==
documentation?.amends?.amends?.subject &&
documentation.amends.amends.subject.id !==
documentation.subject.id
"
:subject="documentation.lessonEvent.amends.subject"
:subject="documentation.amends.amends.subject"
v-bind="compact ? dialogActivator.attrs : {}"
v-on="compact ? dialogActivator.on : {}"
class="text-decoration-line-through"
......@@ -102,10 +102,10 @@ export default {
},
amendedTeachers() {
if (
this.documentation?.lessonEvent?.amends?.teachers &&
this.documentation.lessonEvent.amends.teachers.length
this.documentation?.amends?.amends?.teachers &&
this.documentation.amends.amends.teachers.length
) {
return this.documentation.lessonEvent.amends.teachers.filter(
return this.documentation.amends.amends.teachers.filter(
(at) => !this.documentation.teachers.includes((t) => t.id === at.id),
);
}
......
......@@ -486,17 +486,17 @@ class Documentation(CalendarEvent):
def get_subject(self) -> str:
if self.subject:
return self.subject
if self.lesson_event:
if self.lesson_event.subject:
return self.lesson_event.subject
if self.lesson_event.course:
return self.lesson_event.course.subject
if self.amends:
if self.amends.subject:
return self.amends.subject
if self.amends.course:
return self.amends.course.subject
if self.course:
return self.course.subject
def get_groups(self) -> QuerySet[Group]:
if self.lesson_event:
return self.lesson_event.actual_groups
if self.amends:
return self.amends.actual_groups
if self.course:
return self.course.groups.all()
......@@ -589,7 +589,7 @@ class Documentation(CalendarEvent):
docs.append(
cls(
pk=f"DUMMY;{event_reference_obj.id};{event['DTSTART'].dt.isoformat()};{event['DTEND'].dt.isoformat()}",
lesson_event=event_reference_obj,
amends=event_reference_obj,
course=course,
subject=subject,
datetime_start=event["DTSTART"].dt,
......
......@@ -39,7 +39,7 @@ class Query(graphene.ObjectType):
def resolve_documentations_by_course_id(root, info, course_id, **kwargs):
documentations = Documentation.objects.filter(
Q(course__pk=course_id) | Q(lesson_event__course__pk=course_id)
Q(course__pk=course_id) | Q(amends__course__pk=course_id)
)
return documentations
......
......@@ -28,7 +28,7 @@ class DocumentationType(PermissionsTypeMixin, DjangoFilterMixin, DjangoObjectTyp
fields = (
"id",
"course",
"lesson_event",
"amends",
"subject",
"topic",
"homework",
......@@ -55,12 +55,12 @@ class DocumentationType(PermissionsTypeMixin, DjangoFilterMixin, DjangoObjectTyp
def resolve_teachers(root: Documentation, info, **kwargs):
if not str(root.pk).startswith("DUMMY") and hasattr(root, "teachers"):
return root.teachers
elif root.lesson_event.amends:
if root.lesson_event.teachers:
return root.lesson_event.teachers
elif root.amends.amends:
if root.amends.teachers:
return root.amends.teachers
else:
return root.lesson_event.amends.teachers
return root.lesson_event.teachers
return root.amends.amends.teachers
return root.amends.teachers
@staticmethod
def resolve_future_notice(root: Documentation, info, **kwargs):
......@@ -148,7 +148,7 @@ class DocumentationBatchCreateOrUpdateMutation(graphene.Mutation):
obj = Documentation.objects.create(
datetime_start=datetime_start,
datetime_end=datetime_end,
lesson_event=lesson_event,
amends=lesson_event,
course=course,
subject=subject,
topic=doc.topic or "",
......
......@@ -390,13 +390,13 @@ def is_documentation_teacher(user: User, obj: Documentation):
if obj:
if not str(obj.pk).startswith("DUMMY") and hasattr(obj, "teachers"):
teachers = obj.teachers
elif obj.lesson_event.amends:
if obj.lesson_event.teachers:
teachers = obj.lesson_event.teachers
elif obj.amends.amends:
if obj.amends.teachers:
teachers = obj.amends.teachers
else:
teachers = obj.lesson_event.amends.teachers
teachers = obj.amends.amends.teachers
else:
teachers = obj.lesson_event.teachers
teachers = obj.amends.teachers
return user.person in teachers.all()
return False
......@@ -407,11 +407,11 @@ def can_view_documentation(user: User, obj: Documentation):
if obj:
if is_documentation_teacher(user, obj):
return True
if obj.lesson_event:
if obj.amends:
return (
is_lesson_event_teacher(user, obj.lesson_event)
| is_lesson_event_member(user, obj.lesson_event)
| is_lesson_event_group_owner(user, obj.lesson_event)
is_lesson_event_teacher(user, obj.amends)
| is_lesson_event_member(user, obj.amends)
| is_lesson_event_group_owner(user, obj.amends)
)
if obj.course:
return is_course_teacher(user, obj.course)
......@@ -425,7 +425,7 @@ def can_view_any_documentation(user: User):
return Documentation.objects.filter(
Q(teachers=user.person)
| Q(lesson_event__in=allowed_lesson_events)
| Q(amends__in=allowed_lesson_events)
| Q(course__teachers=user.person)
).exists()
......@@ -436,9 +436,9 @@ def can_edit_documentation(user: User, obj: Documentation):
if obj:
if is_documentation_teacher(user, obj):
return True
if obj.lesson_event:
return is_lesson_event_teacher(user, obj.lesson_event) | is_lesson_event_group_owner(
user, obj.lesson_event
if obj.amends:
return is_lesson_event_teacher(user, obj.amends) | is_lesson_event_group_owner(
user, obj.amends
)
return False
......
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