Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Alsijil
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-Alsijil
Commits
515daca6
Verified
Commit
515daca6
authored
2 years ago
by
magicfelix
Browse files
Options
Downloads
Patches
Plain Diff
Automatically create LessonDocumentations for past periods
parent
cd7eeebf
No related branches found
Branches containing commit
No related tags found
1 merge request
!284
Draft: Redesign entering of lesson documentation
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/apps/alsijil/schema.py
+20
-5
20 additions, 5 deletions
aleksis/apps/alsijil/schema.py
with
20 additions
and
5 deletions
aleksis/apps/alsijil/schema.py
+
20
−
5
View file @
515daca6
import
graphene
from
datetime
import
datetime
from
graphene_django
import
DjangoObjectType
from
graphene_django.forms.mutation
import
DjangoModelFormMutation
from
aleksis.apps.chronos.models
import
LessonPeriod
from
aleksis.core.models
import
Person
,
Group
from
.forms
import
LessonDocumentationForm
from
.models
import
Event
,
ExcuseType
,
ExtraLesson
,
LessonDocumentation
,
LessonPeriod
,
PersonalNote
,
ExtraMark
from
aleksis.apps.chronos.models
import
Lesson
from
aleksis.core.models
import
Group
,
Person
from
.models
import
(
Event
,
ExcuseType
,
ExtraLesson
,
ExtraMark
,
LessonDocumentation
,
LessonPeriod
,
PersonalNote
,
)
class
ExcuseTypeType
(
DjangoObjectType
):
...
...
@@ -199,7 +208,13 @@ class Query(graphene.ObjectType):
def
resolve_lesson_documentation_by_id
(
root
,
info
,
id
,
**
kwargs
):
return
LessonDocumentation
.
objects
.
get
(
id
=
id
)
def
resolve_lesson_documentations_by_lesson_id
(
root
,
info
,
id
,
**
kwargs
):
def
resolve_lesson_documentations_by_lesson_id
(
root
,
info
,
id
,
**
kwargs
):
# noqa
lesson
=
Lesson
.
objects
.
get
(
id
=
id
)
now
=
datetime
.
now
()
for
planned
in
lesson
.
planned_lessonperiods_datetimes
:
if
planned
[
"
datetime_start
"
]
<=
now
:
LessonDocumentation
.
objects
.
get_or_create
(
week
=
planned
[
"
week
"
],
year
=
planned
[
"
year
"
],
lesson_period
=
planned
[
"
lesson_period
"
])
# FIXME: Queries shouldn't alter data
return
LessonDocumentation
.
objects
.
filter
(
lesson_period_id__in
=
LessonPeriod
.
objects
.
filter
(
lesson_id
=
id
...
...
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