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

Merge branch '343-room-substitutions-are-not-shown-correctly' into 'master'

Resolve "Room substitutions are not shown correctly"

Closes #343

See merge request !454
parents bd736269 9f636abc
No related branches found
No related tags found
1 merge request!454Resolve "Room substitutions are not shown correctly"
Pipeline #194600 failed
...@@ -10,25 +10,16 @@ import SubjectChipSelectField from "aleksis.apps.cursus/components/SubjectChipSe ...@@ -10,25 +10,16 @@ import SubjectChipSelectField from "aleksis.apps.cursus/components/SubjectChipSe
<div class="d-flex"> <div class="d-flex">
<documentation-status v-if="compact" v-bind="documentationPartProps" /> <documentation-status v-if="compact" v-bind="documentationPartProps" />
<div <div
v-if="documentation.amends?.slotNumberStart" v-if="slotNumberStart"
:class="{ :class="{
'text-h5 mr-3 d-flex flex-column justify-center slot-number': true, 'text-h5 mr-3 d-flex flex-column justify-center slot-number': true,
'ml-2 slot-number-mobile': !largeGrid, 'ml-2 slot-number-mobile': !largeGrid,
}" }"
> >
<span <span v-if="slotNumberStart == slotNumberEnd">
v-if=" {{ slotNumberStart }}.
documentation.amends?.slotNumberStart ==
documentation.amends?.slotNumberEnd
"
>
{{ documentation.amends?.slotNumberStart }}.
</span>
<span v-else>
{{ documentation.amends?.slotNumberStart }}.–{{
documentation.amends?.slotNumberEnd
}}.
</span> </span>
<span v-else> {{ slotNumberStart }}.–{{ slotNumberEnd }}. </span>
</div> </div>
<div :class="{ 'text-right d-flex flex-column fit-content': largeGrid }"> <div :class="{ 'text-right d-flex flex-column fit-content': largeGrid }">
<time :datetime="documentation.datetimeStart" class="text-no-wrap"> <time :datetime="documentation.datetimeStart" class="text-no-wrap">
...@@ -94,22 +85,14 @@ import SubjectChipSelectField from "aleksis.apps.cursus/components/SubjectChipSe ...@@ -94,22 +85,14 @@ import SubjectChipSelectField from "aleksis.apps.cursus/components/SubjectChipSe
}" }"
> >
<person-chip <person-chip
v-for="teacher in documentation.teachers" v-for="teacher in teachersWithStatus"
:key="documentation.id + '-teacher-' + teacher.id" :key="documentation.id + '-teacher-' + teacher.id"
:person="teacher" :person="teacher"
:no-link="compact" :no-link="compact"
v-bind="compact ? dialogActivator.attrs : {}" v-bind="compact ? dialogActivator.attrs : {}"
v-on="compact ? dialogActivator.on : {}" v-on="compact ? dialogActivator.on : {}"
/> :class="{ 'text-decoration-line-through': teacher?.removed }"
<person-chip :disabled="teacher?.removed"
v-for="teacher in amendedTeachers"
:key="documentation.id + '-amendedTeacher-' + teacher.id"
:person="teacher"
:no-link="compact"
v-bind="compact ? dialogActivator.attrs : {}"
v-on="compact ? dialogActivator.on : {}"
class="text-decoration-line-through"
disabled
/> />
</div> </div>
</div> </div>
...@@ -147,16 +130,50 @@ export default { ...@@ -147,16 +130,50 @@ export default {
largeGrid() { largeGrid() {
return this.compact && !this.$vuetify.breakpoint.mobile; return this.compact && !this.$vuetify.breakpoint.mobile;
}, },
amendedTeachers() { // Group teachers by their substitution status (regular, removed)
if ( teachersWithStatus() {
this.documentation?.amends?.amends?.teachers && if (this.documentation?.amends?.amends) {
this.documentation.amends.amends.teachers.length // Only do grouping if documentation is based on substitution and substitution
) { // has teachers linked with it.
return this.documentation.amends.amends.teachers.filter( if (this.documentation.teachers.length > 0) {
(at) => !this.documentation.teachers.includes((t) => t.id === at.id), // IDs of teachers of amended lesson
); const oldIds = this.documentation.amends.amends.teachers.map(
(teacher) => teacher.id,
);
// IDs of teachers of new substitution lesson
const newIds = this.documentation.teachers.map(
(teacher) => teacher.id,
);
const allTeachers = new Set(
this.documentation.amends.amends.teachers.concat(
this.documentation.teachers,
),
);
let teachersWithStatus = Array.from(allTeachers).map((teacher) => {
let removed = false;
if (!newIds.includes(teacher.id) && oldIds.includes(teacher.id)) {
// Mark teacher as being removed if they are only linked to the amended lesson
removed = true;
}
return { ...teacher, removed: removed };
});
return teachersWithStatus;
}
return this.documentation.amends.amends.teachers;
}
return this.documentation.teachers;
},
slotNumberStart() {
if (this.documentation?.amends?.amends?.slotNumberStart) {
return this.documentation.amends.amends.slotNumberStart;
}
return this.documentation.amends?.slotNumberStart;
},
slotNumberEnd() {
if (this.documentation?.amends?.amends?.slotNumberEnd) {
return this.documentation.amends.amends.slotNumberEnd;
} }
return []; return this.documentation.amends?.slotNumberEnd;
}, },
}, },
}; };
......
...@@ -193,6 +193,7 @@ def is_lesson_event_group_owner(user: User, obj: LessonEvent): ...@@ -193,6 +193,7 @@ def is_lesson_event_group_owner(user: User, obj: LessonEvent):
Checks whether the person linked to the user is a owner of any group Checks whether the person linked to the user is a owner of any group
(or their respective parent groups) linked to the lesson event, (or their respective parent groups) linked to the lesson event,
or a owner of any group linked to the course, if the lesson event has one. or a owner of any group linked to the course, if the lesson event has one.
Also checks for groups linked to the lesson being amended, if one exists.
""" """
if obj: if obj:
for g in obj.groups.all(): for g in obj.groups.all():
...@@ -201,6 +202,13 @@ def is_lesson_event_group_owner(user: User, obj: LessonEvent): ...@@ -201,6 +202,13 @@ def is_lesson_event_group_owner(user: User, obj: LessonEvent):
for pg in g.parent_groups.all(): for pg in g.parent_groups.all():
if user.person in pg.owners.all(): if user.person in pg.owners.all():
return True return True
if obj.amends:
for g in obj.amends.groups.all():
if user.person in g.owners.all():
return True
for pg in g.parent_groups.all():
if user.person in pg.owners.all():
return True
return False 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