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
e1bac805
Commit
e1bac805
authored
2 years ago
by
Julian
Browse files
Options
Downloads
Patches
Plain Diff
Update schema to support editing and creation of personal notes
parent
01195ff2
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/alsijil/schema.py
+24
-19
24 additions, 19 deletions
aleksis/apps/alsijil/schema.py
with
24 additions
and
19 deletions
aleksis/apps/alsijil/schema.py
+
24
−
19
View file @
e1bac805
...
@@ -4,7 +4,7 @@ from graphene_django.forms.mutation import DjangoModelFormMutation
...
@@ -4,7 +4,7 @@ from graphene_django.forms.mutation import DjangoModelFormMutation
from
aleksis.apps.chronos.models
import
LessonPeriod
from
aleksis.apps.chronos.models
import
LessonPeriod
from
aleksis.core.models
import
Person
,
Group
from
aleksis.core.models
import
Person
,
Group
from
.forms
import
LessonDocumentationForm
,
PersonalNoteForm
from
.forms
import
LessonDocumentationForm
from
.models
import
ExcuseType
,
LessonDocumentation
,
PersonalNote
,
ExtraMark
from
.models
import
ExcuseType
,
LessonDocumentation
,
PersonalNote
,
ExtraMark
...
@@ -58,18 +58,13 @@ class LessonDocumentationMutation(DjangoModelFormMutation):
...
@@ -58,18 +58,13 @@ class LessonDocumentationMutation(DjangoModelFormMutation):
form_class
=
LessonDocumentationForm
form_class
=
LessonDocumentationForm
class
PersonalNoteMutation
(
DjangoModelFormMutation
):
class
PersonalNoteMutation
(
graphene
.
Mutation
):
personal_note
=
graphene
.
Field
(
PersonalNoteType
)
class
Meta
:
form_class
=
PersonalNoteForm
class
CreatePersonalNoteMutation
(
graphene
.
Mutation
):
class
Arguments
:
class
Arguments
:
person_id
=
graphene
.
ID
(
required
=
True
)
person_id
=
graphene
.
ID
(
required
=
True
)
lesson_documentation
=
graphene
.
ID
(
required
=
True
)
lesson_documentation
=
graphene
.
ID
(
required
=
True
)
personal_note_id
=
graphene
.
ID
(
required
=
False
)
# Update or create personal note
late
=
graphene
.
Int
(
required
=
False
)
late
=
graphene
.
Int
(
required
=
False
)
absent
=
graphene
.
Boolean
(
required
=
False
)
absent
=
graphene
.
Boolean
(
required
=
False
)
excused
=
graphene
.
Boolean
(
required
=
False
)
excused
=
graphene
.
Boolean
(
required
=
False
)
...
@@ -86,6 +81,7 @@ class CreatePersonalNoteMutation(graphene.Mutation):
...
@@ -86,6 +81,7 @@ class CreatePersonalNoteMutation(graphene.Mutation):
info
,
info
,
person_id
,
person_id
,
lesson_documentation
,
lesson_documentation
,
personal_note_id
=
None
,
late
=
0
,
late
=
0
,
absent
=
False
,
absent
=
False
,
excused
=
False
,
excused
=
False
,
...
@@ -95,32 +91,41 @@ class CreatePersonalNoteMutation(graphene.Mutation):
...
@@ -95,32 +91,41 @@ class CreatePersonalNoteMutation(graphene.Mutation):
):
):
if
extra_marks
is
None
:
if
extra_marks
is
None
:
extra_marks
=
[]
extra_marks
=
[]
person
=
Person
.
objects
.
get
(
pk
=
person_id
)
person
=
Person
.
objects
.
get
(
pk
=
person_id
)
lesson_documentation
=
LessonDocumentation
.
objects
.
get
(
pk
=
lesson_documentation
)
lesson_documentation
=
LessonDocumentation
.
objects
.
get
(
pk
=
lesson_documentation
)
extra_marks
=
ExtraMark
.
objects
.
filter
(
pk__in
=
extra_marks
)
personal_note
=
PersonalNote
.
objects
.
create
(
personal_note
,
created
=
PersonalNote
.
objects
.
get_or_
create
(
person
=
person
,
person
=
person
,
event
=
lesson_documentation
.
event
,
event
=
lesson_documentation
.
event
,
extra_lesson
=
lesson_documentation
.
extra_lesson
,
extra_lesson
=
lesson_documentation
.
extra_lesson
,
lesson_period
=
lesson_documentation
.
lesson_period
,
lesson_period
=
lesson_documentation
.
lesson_period
,
late
=
late
,
absent
=
absent
,
excused
=
excused
,
excuse_type
=
excuse_type
,
remarks
=
remarks
,
week
=
lesson_documentation
.
week
,
week
=
lesson_documentation
.
week
,
year
=
lesson_documentation
.
year
,
year
=
lesson_documentation
.
year
,
)
)
if
late
:
personal_note
.
late
=
late
if
absent
is
not
None
:
personal_note
.
absent
=
absent
if
excused
is
not
None
:
personal_note
.
excused
=
excused
if
excuse_type
:
personal_note
.
excuse_type
=
ExcuseType
.
objects
.
get
(
pk
=
excuse_type
)
if
remarks
:
personal_note
.
remarks
=
remarks
personal_note
.
save
()
extra_marks
=
ExtraMark
.
objects
.
filter
(
pk__in
=
extra_marks
)
personal_note
.
extra_marks
.
set
(
extra_marks
)
personal_note
.
extra_marks
.
set
(
extra_marks
)
personal_note
.
groups_of_person
.
set
(
person
.
member_of
.
all
())
personal_note
.
groups_of_person
.
set
(
person
.
member_of
.
all
())
personal_note
.
save
()
personal_note
.
save
()
return
Create
PersonalNoteMutation
(
personal_note
=
personal_note
)
return
PersonalNoteMutation
(
personal_note
=
personal_note
)
class
Mutation
(
graphene
.
ObjectType
):
class
Mutation
(
graphene
.
ObjectType
):
update_lesson_documentation
=
LessonDocumentationMutation
.
Field
()
update_lesson_documentation
=
LessonDocumentationMutation
.
Field
()
create_personal_note
=
Create
PersonalNoteMutation
.
Field
()
update_or_
create_personal_note
=
PersonalNoteMutation
.
Field
()
update_personal_note
=
PersonalNoteMutation
.
Field
()
#
update_personal_note = PersonalNoteMutation.Field()
class
Query
(
graphene
.
ObjectType
):
class
Query
(
graphene
.
ObjectType
):
...
...
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