diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/documentation/DocumentationStatus.vue b/aleksis/apps/alsijil/frontend/components/coursebook/documentation/DocumentationStatus.vue index deb5dda390e165ca801d76faafec6e5874d16ed2..a797465e981633240063f4266ebbeb036acc9421 100644 --- a/aleksis/apps/alsijil/frontend/components/coursebook/documentation/DocumentationStatus.vue +++ b/aleksis/apps/alsijil/frontend/components/coursebook/documentation/DocumentationStatus.vue @@ -102,16 +102,33 @@ export default { } }, }, + watch: { + documentation: { + handler() { + this.updateStatus(); + }, + deep: true, + } + }, mounted() { this.updateStatus(); - this.statusTimeout = setTimeout( - this.updateStatus, - this.documentationDateTimeStart.diff(DateTime.now(), "seconds").toObject() - .seconds, - ); + + if (DateTime.now() < this.documentationDateTimeStart) { + this.statusTimeout = setTimeout( + this.updateStatus, + this.documentationDateTimeStart.diff(DateTime.now(), "seconds").toObject(), + ); + } else if (DateTime.now() < this.documentationDateTimeEnd) { + this.statusTimeout = setTimeout( + this.updateStatus, + this.documentationDateTimeEnd.diff(DateTime.now(), "seconds").toObject(), + ); + } }, beforeDestroy() { - clearTimeout(this.statusTimeout); + if (this.statusTimeout) { + clearTimeout(this.statusTimeout); + } }, }; </script> diff --git a/aleksis/apps/alsijil/frontend/components/coursebook/documentation/LessonSummary.vue b/aleksis/apps/alsijil/frontend/components/coursebook/documentation/LessonSummary.vue index f9c7aeb4b8d90232d144530637e5330c414e0f76..bddf96b2f8a00cc581acc97fd77f1a9e0a82adf8 100644 --- a/aleksis/apps/alsijil/frontend/components/coursebook/documentation/LessonSummary.vue +++ b/aleksis/apps/alsijil/frontend/components/coursebook/documentation/LessonSummary.vue @@ -160,11 +160,11 @@ export default { (o) => o[itemId] === this.documentation.id, ); // merged with the incoming partial documentation - // set ID of documentation currently being edited as oldID so that key in coursebook doesn't change + // if creation of proper documentation from dummy one, set ID of documentation currently being edited as oldID so that key in coursebook doesn't change cached[index] = { ...this.documentation, ...object, - oldId: this.documentation.id, + oldId: this.documentation.id !== object.id ? this.documentation.id : this.documentation.oldId, }; } return cached; diff --git a/aleksis/apps/alsijil/models.py b/aleksis/apps/alsijil/models.py index 789086cc186cac5606abc6484c88c9b26ea62d53..b922c465815624cc49f4e809913ff6321c6dccdf 100644 --- a/aleksis/apps/alsijil/models.py +++ b/aleksis/apps/alsijil/models.py @@ -574,8 +574,8 @@ class Documentation(CalendarEvent): existing_documentations := ( event_reference_obj := event["REFERENCE_OBJECT"] ).documentation.filter( - datetime_start=event["DTSTART"].dt.replace(tzinfo=timezone.utc), - datetime_end=event["DTEND"].dt.replace(tzinfo=timezone.utc), + datetime_start=event["DTSTART"].dt, + datetime_end=event["DTEND"].dt, ) ).exists() else cls( diff --git a/aleksis/apps/alsijil/schema/documentation.py b/aleksis/apps/alsijil/schema/documentation.py index 6d623a39d8f48dc0882bc2164f053c977335a769..0c9082e013031561ef170419b00d9bf52cdb686a 100644 --- a/aleksis/apps/alsijil/schema/documentation.py +++ b/aleksis/apps/alsijil/schema/documentation.py @@ -181,9 +181,8 @@ class DocumentationBatchCreateOrUpdateMutation(graphene.Mutation): # Timezone removal is necessary due to ISO style offsets are no valid timezones. # Instead, we take the timezone from the lesson_event and save it in a dedicated field. obj = Documentation.objects.create( - datetime_start=datetime.fromisoformat(datetime_start).replace(tzinfo=timezone.utc), - datetime_end=datetime.fromisoformat(datetime_end).replace(tzinfo=timezone.utc), - timezone=lesson_event.timezone, + datetime_start=datetime.fromisoformat(datetime_start).astimezone(lesson_event.timezone), + datetime_end=datetime.fromisoformat(datetime_end).astimezone(lesson_event.timezone), lesson_event=lesson_event, course=lesson_event.course, subject=lesson_event.subject,