Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Chronos
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-App-Chronos
Commits
3d00d7ee
Commit
3d00d7ee
authored
7 months ago
by
Julian
Browse files
Options
Downloads
Patches
Plain Diff
Remove special time handling
parent
3c2a4aa0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/apps/chronos/schema/__init__.py
+8
-28
8 additions, 28 deletions
aleksis/apps/chronos/schema/__init__.py
with
8 additions
and
28 deletions
aleksis/apps/chronos/schema/__init__.py
+
8
−
28
View file @
3d00d7ee
...
...
@@ -2,13 +2,13 @@ from datetime import timezone
import
graphene
from
graphene_django
import
DjangoObjectType
from
graphene_django_cud.mutations
import
(
DjangoBatchCreateMutation
,
DjangoBatchDeleteMutation
,
DjangoBatchPatchMutation
,
)
from
aleksis.core.models
import
Group
,
Person
,
Room
from
aleksis.core.schema.base
import
(
BaseBatchCreateMutation
,
BaseBatchDeleteMutation
,
BaseBatchPatchMutation
,
)
from
..models
import
LessonEvent
from
..util.chronos_helpers
import
get_groups
,
get_rooms
,
get_teachers
...
...
@@ -60,27 +60,7 @@ class LessonEventType(DjangoObjectType):
amends
=
graphene
.
Field
(
lambda
:
LessonEventType
,
required
=
False
)
class
DatetimeTimezoneMixin
:
"""
Handle datetimes for mutations with CalendarEvent objects.
This is necessary because the client sends timezone information as
ISO string which only includes an offset (+00:00 UTC) and an
offset is not a valid timezone. Instead we set UTC as timezone
here directly.
"""
@classmethod
def
handle_datetime_start
(
cls
,
value
,
name
,
info
)
->
int
:
value
=
value
.
replace
(
tzinfo
=
timezone
.
utc
)
return
value
@classmethod
def
handle_datetime_end
(
cls
,
value
,
name
,
info
)
->
int
:
value
=
value
.
replace
(
tzinfo
=
timezone
.
utc
)
return
value
class
AmendLessonBatchCreateMutation
(
DatetimeTimezoneMixin
,
DjangoBatchCreateMutation
):
class
AmendLessonBatchCreateMutation
(
BaseBatchCreateMutation
):
class
Meta
:
model
=
LessonEvent
permissions
=
(
"
chronos.edit_substitution_rule
"
,)
...
...
@@ -103,7 +83,7 @@ class AmendLessonBatchCreateMutation(DatetimeTimezoneMixin, DjangoBatchCreateMut
return
created_objects
class
AmendLessonBatchPatchMutation
(
DatetimeTimezoneMixin
,
Django
BatchPatchMutation
):
class
AmendLessonBatchPatchMutation
(
Base
BatchPatchMutation
):
class
Meta
:
model
=
LessonEvent
permissions
=
(
"
chronos.edit_substitution_rule
"
,)
...
...
@@ -116,7 +96,7 @@ class AmendLessonBatchPatchMutation(DatetimeTimezoneMixin, DjangoBatchPatchMutat
return
updated_objects
class
AmendLessonBatchDeleteMutation
(
Django
BatchDeleteMutation
):
class
AmendLessonBatchDeleteMutation
(
Base
BatchDeleteMutation
):
class
Meta
:
model
=
LessonEvent
permissions
=
(
"
chronos.delete_substitution_rule
"
,)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment