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

Use reversion for coursebook entries

parent c035f05e
No related branches found
No related tags found
2 merge requests!352Draft: Resolve "Add dialog with each lesson's students",!350Resolve "Add simple course book list"
Pipeline #178680 failed
......@@ -6,6 +6,7 @@ from django.utils.timezone import localdate, localtime
import graphene
from graphene_django.types import DjangoObjectType
from guardian.shortcuts import get_objects_for_user
from reversion import create_revision, set_comment, set_user
from aleksis.apps.alsijil.util.predicates import can_edit_documentation, is_in_allowed_time_range
from aleksis.apps.chronos.models import LessonEvent
......@@ -117,8 +118,6 @@ class DocumentationBatchCreateOrUpdateMutation(graphene.Mutation):
and datetime_start <= localtime()
)
):
# 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_start,
datetime_end=datetime_end,
......@@ -159,6 +158,9 @@ class DocumentationBatchCreateOrUpdateMutation(graphene.Mutation):
@classmethod
def mutate(cls, root, info, input): # noqa
objs = [cls.create_or_update(info, doc) for doc in input]
with create_revision():
set_user(info.context.user)
set_comment("Updated in coursebook")
objs = [cls.create_or_update(info, doc) for doc in input]
return DocumentationBatchCreateOrUpdateMutation(documentations=objs)
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