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

Fix displaying of subjects in lesson feed

parent 04a916ce
No related branches found
No related tags found
1 merge request!310Resolve "Implement Vue substitution frontend"
Pipeline #144770 failed
......@@ -29,7 +29,7 @@ export default {
><lesson-event-link-iterator :items="oldItems" :attr="attr"
/></span>
<!-- eslint-disable-next-line @intlify/vue-i18n/no-raw-text -->
<span></span>
<span></span>
<lesson-event-link-iterator :items="newItems" :attr="attr" />
</span>
<span v-else-if="newItems.length > 0">
......
......@@ -26,13 +26,13 @@ export default {
{{ event.meta.amends.subject[attr] }}</span
>
<!-- eslint-disable-next-line @intlify/vue-i18n/no-raw-text -->
<span></span>
{{ event.meta.subject[attr] }}
<span></span>
<span>{{ event.meta.subject[attr] }}</span>
</span>
<span v-else-if="event.meta.subject">
{{ event.meta.subject[attr] }}
</span>
<span v-else-if="event.amended && event.amends.subject">
<span v-else-if="event.meta.amended && event.meta.amends.subject">
{{ event.meta.amends.subject[attr] }}
</span>
<span v-else>
......
......@@ -149,16 +149,10 @@
/>
</template>
<template #cancelled.field="{ attrs, on }">
<v-checkbox
v-bind="attrs"
v-on="on"
/>
<v-checkbox v-bind="attrs" v-on="on" />
</template>
<template #comment.field="{ attrs, on }">
<v-textarea
v-bind="attrs"
v-on="on"
/>
<v-textarea v-bind="attrs" v-on="on" />
</template>
</dialog-object-form>
</v-card-actions>
......@@ -183,7 +177,7 @@ import {
gqlPersons,
gqlRooms,
createAmendLesson,
patchAmendLesson
patchAmendLesson,
} from "../../amendLesson.graphql";
export default {
......@@ -229,7 +223,7 @@ export default {
comment: this.selectedEvent.meta.comment,
},
gqlCreateMutation: createAmendLesson,
gqlPatchMutation: patchAmendLesson
gqlPatchMutation: patchAmendLesson,
},
};
},
......@@ -239,8 +233,8 @@ export default {
...item,
amends: this.selectedEvent.meta.id,
// LessonEvent has datetime in UTC & graphql does not like the Z timezone info
datetimeStart: this.selectedEvent.start.toISOString().replace('Z', ''),
datetimeEnd: this.selectedEvent.end.toISOString().replace('Z', ''),
datetimeStart: this.selectedEvent.start.toISOString().replace("Z", ""),
datetimeEnd: this.selectedEvent.end.toISOString().replace("Z", ""),
};
},
transformPatchData(item) {
......
......@@ -1468,14 +1468,16 @@ class LessonEvent(CalendarEvent):
@property
def subject_name_with_amends(self: "LessonEvent") -> str:
my_subject = self.subject.name
my_subject = self.subject.name if self.subject else ""
amended_subject = self.real_amends.subject.name if self.amends else ""
if my_subject and amended_subject:
return _("{} (instead of {})").format(my_subject, amended_subject)
elif not my_subject and amended_subject:
return amended_subject
return my_subject
elif my_subject:
return my_subject
return _("Lesson")
@property
def real_amends(self: "LessonEvent") -> "LessonEvent":
......@@ -1489,14 +1491,16 @@ class LessonEvent(CalendarEvent):
"""Get the title of the event."""
if reference_object.title:
return reference_object.title
elif reference_object.subject:
title = reference_object.subject.name
elif reference_object.subject or (
reference_object.amends and reference_object.real_amends.subject
):
title = reference_object.subject_name_with_amends
if request.user.person in reference_object.teachers.all():
title += " · " + reference_object.group_names
else:
title += " · " + reference_object.teacher_names
title += " · " + reference_object.teacher_names_with_amends
if reference_object.rooms.all().exists():
title += " · " + reference_object.room_names
title += " · " + reference_object.room_names_with_amends
return title
return _("Lesson")
......
......@@ -2,9 +2,9 @@ import graphene
from graphene_django import DjangoObjectType
from graphene_django_cud.mutations import DjangoCreateMutation, DjangoPatchMutation
from aleksis.core.models import Group, Person, Room, CalendarEvent
from ..models import LessonEvent
from aleksis.core.models import CalendarEvent, Group, Person, Room
from ..models import LessonEvent
from ..util.chronos_helpers import get_classes, get_rooms, get_teachers
......@@ -35,53 +35,48 @@ class TimetableRoomType(DjangoObjectType):
class CalendarEventForLessonEventType(DjangoObjectType):
class Meta:
model = CalendarEvent
fields = ("id",
"amends",
"datetime_start",
"datetime_end")
fields = ("id", "amends", "datetime_start", "datetime_end")
class LessonEventType(DjangoObjectType):
class Meta:
model = LessonEvent
fields = ("id",
"amends",
"datetime_start",
"datetime_end",
"subject",
"teachers",
"groups",
"rooms",
"cancelled",
"comment")
fields = (
"id",
"amends",
"datetime_start",
"datetime_end",
"subject",
"teachers",
"groups",
"rooms",
"cancelled",
"comment",
)
class AmendLessonCreateMutation(DjangoCreateMutation):
class Meta:
model = LessonEvent
permissions = ("chronos.edit_substitution_rule",)
only_fields = ("amends",
"datetime_start",
"datetime_end",
"subject",
"teachers",
"groups",
"rooms",
"cancelled",
"comment")
only_fields = (
"amends",
"datetime_start",
"datetime_end",
"subject",
"teachers",
"groups",
"rooms",
"cancelled",
"comment",
)
class AmendLessonPatchMutation(DjangoPatchMutation):
class Meta:
model = LessonEvent
permissions = ("chronos.edit_substitution_rule",)
only_fields = (
"subject",
"teachers",
"groups",
"rooms",
"cancelled",
"comment")
only_fields = ("subject", "teachers", "groups", "rooms", "cancelled", "comment")
class TimetableType(graphene.Enum):
......
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