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
adf8d2f2
Commit
adf8d2f2
authored
1 year ago
by
Hangzhi Yu
Browse files
Options
Downloads
Patches
Plain Diff
Add filtered queries for groups & courses
parent
b125af74
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!352
Draft: Resolve "Add dialog with each lesson's students"
,
!350
Resolve "Add simple course book list"
Checking pipeline status
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/apps/alsijil/schema/__init__.py
+39
-0
39 additions, 0 deletions
aleksis/apps/alsijil/schema/__init__.py
with
39 additions
and
0 deletions
aleksis/apps/alsijil/schema/__init__.py
+
39
−
0
View file @
adf8d2f2
...
...
@@ -6,8 +6,11 @@ from django.db.models.query_utils import Q
import
graphene
from
aleksis.apps.cursus.models
import
Course
from
aleksis.apps.cursus.schema
import
CourseType
from
aleksis.core.models
import
Group
,
Person
from
aleksis.core.schema.base
import
FilterOrderList
from
aleksis.core.schema.group
import
GroupType
from
aleksis.core.util.core_helpers
import
has_person
from
..models
import
Documentation
from
.documentation
import
(
...
...
@@ -34,6 +37,9 @@ class Query(graphene.ObjectType):
date_end
=
graphene
.
Date
(
required
=
True
),
)
groups_by_person
=
FilterOrderList
(
GroupType
,
person
=
graphene
.
ID
())
courses_of_person
=
FilterOrderList
(
CourseType
,
person
=
graphene
.
ID
())
def
resolve_documentations_by_course_id
(
root
,
info
,
course_id
,
**
kwargs
):
documentations
=
Documentation
.
objects
.
filter
(
Q
(
course__pk
=
course_id
)
|
Q
(
lesson_event__course__pk
=
course_id
)
...
...
@@ -72,6 +78,39 @@ class Query(graphene.ObjectType):
own
,
datetime_start
,
datetime_end
,
info
.
context
,
obj_type
,
obj_id
)
@staticmethod
def
resolve_groups_by_person
(
root
,
info
,
person
=
None
):
if
person
:
person
=
Person
.
objects
.
get
(
pk
=
person
)
if
not
info
.
context
.
user
.
has_perm
(
"
core.view_person_rule
"
,
person
):
raise
PermissionDenied
()
elif
has_person
(
info
.
context
.
user
):
person
=
info
.
context
.
user
.
person
else
:
raise
PermissionDenied
()
return
Group
.
objects
.
filter
(
Q
(
members
=
person
)
|
Q
(
owners
=
person
)
|
Q
(
parent_groups__owners
=
person
)
)
@staticmethod
def
resolve_courses_of_person
(
root
,
info
,
person
=
None
):
if
person
:
person
=
Person
.
objects
.
get
(
pk
=
person
)
if
not
info
.
context
.
user
.
has_perm
(
"
core.view_person_rule
"
,
person
):
raise
PermissionDenied
()
elif
has_person
(
info
.
context
.
user
):
person
=
info
.
context
.
user
.
person
else
:
raise
PermissionDenied
()
return
Course
.
objects
.
filter
(
Q
(
teachers
=
person
)
|
Q
(
groups__members
=
person
)
|
Q
(
groups__owners
=
person
)
|
Q
(
groups__parent_groups__owners
=
person
)
)
class
Mutation
(
graphene
.
ObjectType
):
create_documentation
=
DocumentationCreateMutation
.
Field
()
...
...
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