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
399ccff6
Verified
Commit
399ccff6
authored
2 years ago
by
Julian
Committed by
magicfelix
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Update schema for lesson documentations and personal notes
parent
71c1f583
No related branches found
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
+43
-10
43 additions, 10 deletions
aleksis/apps/alsijil/schema.py
with
43 additions
and
10 deletions
aleksis/apps/alsijil/schema.py
+
43
−
10
View file @
399ccff6
...
@@ -2,25 +2,48 @@ import graphene
...
@@ -2,25 +2,48 @@ import graphene
from
graphene_django
import
DjangoObjectType
from
graphene_django
import
DjangoObjectType
from
graphene_django.forms.mutation
import
DjangoModelFormMutation
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
.forms
import
LessonDocumentationForm
from
.models
import
ExcuseType
,
LessonDocumentation
,
PersonalNote
,
ExtraMark
from
.models
import
ExcuseType
,
LessonDocumentation
,
PersonalNote
,
ExtraMark
# print([ExcuseType, LessonDocumentation, PersonalNote, ExtraMark])
class
ExcuseTypeType
(
DjangoObjectType
):
class
ExcuseTypeType
(
DjangoObjectType
):
class
Meta
:
class
Meta
:
model
=
ExcuseType
model
=
ExcuseType
class
PersonalNoteType
(
DjangoObjectType
):
class
Meta
:
model
=
PersonalNote
class
LessonDocumentationType
(
DjangoObjectType
):
class
LessonDocumentationType
(
DjangoObjectType
):
class
Meta
:
class
Meta
:
model
=
LessonDocumentation
model
=
LessonDocumentation
personal_notes
=
graphene
.
List
(
PersonalNoteType
)
date
=
graphene
.
Field
(
graphene
.
Date
)
period
=
graphene
.
Field
(
graphene
.
Int
)
class
PersonalNoteType
(
DjangoObjectType
):
def
resolve_personal_notes
(
root
:
LessonDocumentation
,
info
,
**
kwargs
):
class
Meta
:
persons
=
Person
.
objects
.
filter
(
model
=
PersonalNote
member_of__in
=
Group
.
objects
.
filter
(
pk__in
=
root
.
register_object
.
get_groups
().
all
()
)
)
return
PersonalNote
.
objects
.
filter
(
week
=
root
.
week
,
year
=
root
.
year
,
lesson_period
=
root
.
lesson_period
,
person__in
=
persons
,
)
def
resolve_period
(
root
:
LessonDocumentation
,
info
,
**
kwargs
):
return
root
.
period
.
period
def
resolve_date
(
root
:
LessonDocumentation
,
info
,
**
kwargs
):
return
root
.
date
class
ExtraMarkType
(
DjangoObjectType
):
class
ExtraMarkType
(
DjangoObjectType
):
...
@@ -38,17 +61,30 @@ class LessonDocumentationMutation(DjangoModelFormMutation):
...
@@ -38,17 +61,30 @@ class LessonDocumentationMutation(DjangoModelFormMutation):
class
Query
(
graphene
.
ObjectType
):
class
Query
(
graphene
.
ObjectType
):
excuse_types
=
graphene
.
List
(
ExcuseTypeType
)
excuse_types
=
graphene
.
List
(
ExcuseTypeType
)
lesson_documentations
=
graphene
.
List
(
LessonDocumentationType
)
lesson_documentations
=
graphene
.
List
(
LessonDocumentationType
)
lesson_documentations_by_lesson_id
=
graphene
.
List
(
LessonDocumentationType
,
id
=
graphene
.
ID
())
personal_notes
=
graphene
.
List
(
PersonalNoteType
)
personal_notes
=
graphene
.
List
(
PersonalNoteType
)
extra_marks
=
graphene
.
List
(
ExtraMarkType
)
extra_marks
=
graphene
.
List
(
ExtraMarkType
)
def
resolve_excuse_types
(
root
,
info
,
**
kwargs
):
def
resolve_excuse_types
(
root
,
info
,
**
kwargs
):
# FIXME do permission stuff
# FIXME do permission stuff
print
(
ExcuseType
.
objects
.
all
())
return
ExcuseType
.
objects
.
all
()
return
ExcuseType
.
objects
.
all
()
def
resolve_lesson_documentations
(
root
,
info
,
**
kwargs
):
def
resolve_lesson_documentations
(
root
,
info
,
**
kwargs
):
# FIXME do permission stuff
# FIXME do permission stuff
return
LessonDocumentation
.
objects
.
all
()
return
LessonDocumentation
.
objects
.
all
().
order_by
(
"
-year
"
,
"
-week
"
,
"
-lesson_period__period__weekday
"
,
"
-lesson_period__period__period
"
)
def
resolve_lesson_documentations_by_lesson_id
(
root
,
info
,
id
,
**
kwargs
):
return
LessonDocumentation
.
objects
.
filter
(
lesson_period_id__in
=
LessonPeriod
.
objects
.
filter
(
lesson_id
=
id
).
values_list
(
"
id
"
,
flat
=
True
)
).
order_by
(
"
-year
"
,
"
-week
"
,
"
-lesson_period__period__weekday
"
,
"
-lesson_period__period__period
"
)
def
resolve_personal_notes
(
root
,
info
,
**
kwargs
):
def
resolve_personal_notes
(
root
,
info
,
**
kwargs
):
# FIXME do permission stuff
# FIXME do permission stuff
...
@@ -56,6 +92,3 @@ class Query(graphene.ObjectType):
...
@@ -56,6 +92,3 @@ class Query(graphene.ObjectType):
def
resolve_extra_marks
(
root
,
info
,
**
kwargs
):
def
resolve_extra_marks
(
root
,
info
,
**
kwargs
):
return
ExtraMark
.
objects
.
all
()
return
ExtraMark
.
objects
.
all
()
# print("Hello2")
# schema = graphene.Schema(query=Query)
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