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
21863194
Commit
21863194
authored
1 year ago
by
Julian
Browse files
Options
Downloads
Patches
Plain Diff
Create endpoint for real and dummy documentations in a timeframe
parent
9ea0ed66
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"
Pipeline
#166270
failed
1 year ago
Stage: prepare
Stage: test
Stage: build
Stage: publish
Stage: docker
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/apps/alsijil/models.py
+34
-1
34 additions, 1 deletion
aleksis/apps/alsijil/models.py
aleksis/apps/alsijil/schema/__init__.py
+14
-0
14 additions, 0 deletions
aleksis/apps/alsijil/schema/__init__.py
with
48 additions
and
1 deletion
aleksis/apps/alsijil/models.py
+
34
−
1
View file @
21863194
from
datetime
import
date
from
datetime
import
date
,
datetime
from
typing
import
Optional
,
Union
from
urllib.parse
import
urlparse
import
json
from
django.db
import
models
from
django.db.models
import
QuerySet
from
django.db.models.constraints
import
CheckConstraint
from
django.db.models.query_utils
import
Q
from
django.http
import
HttpRequest
from
django.urls
import
reverse
from
django.utils.formats
import
date_format
from
django.utils.translation
import
gettext_lazy
as
_
...
...
@@ -513,6 +515,37 @@ class Documentation(CalendarEvent):
),
]
@classmethod
def
get_for_coursebook
(
cls
,
obj_type
:
str
,
obj_id
:
str
,
date_start
:
datetime
,
date_end
:
datetime
,
request
:
HttpRequest
)
->
list
:
"""
Get all the documentations for an object and a time frame.
obj_type may be one of TEACHER, GROUP, ROOM, COURSE
"""
# 1. Find all LessonEvents for all Lessons of this Course in this date range
# TODO: verify that substitutions don't break this
events
=
LessonEvent
.
get_single_events
(
date_start
,
date_end
,
request
,
{
"
type
"
:
obj_type
,
"
id
"
:
obj_id
,
},
with_reference_obj
=
True
)
# (1.5 filter them by permissions)
...
# 2. For each lessonEvent → check if there is a documentation
# if so, add the documentation to a list, if not, create a new one
return
[
(
event_reference_obj
.
documentation
.
first
()
# TODO: probably show all documentations
if
(
event_reference_obj
:
=
event
[
"
REFERENCE_OBJ
"
]).
documentation
.
exists
()
else
cls
(
pk
=
f
"
DUMMY:
{
event_reference_obj
.
id
}
"
,
lesson_event
=
event_reference_obj
,
course
=
event_reference_obj
.
course
,
subject
=
event_reference_obj
.
subject
,
datetime_start
=
event
[
"
DTSTART
"
].
dt
,
datetime_end
=
event
[
"
DTEND
"
].
dt
,
)
)
for
event
in
events
]
class
ParticipationStatus
(
ExtensibleModel
):
"""
A participation or absence record about a single person.
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/alsijil/schema/__init__.py
+
14
−
0
View file @
21863194
from
django.db.models.query_utils
import
Q
from
datetime
import
datetime
import
graphene
from
aleksis.core.schema.base
import
FilterOrderList
...
...
@@ -19,6 +20,12 @@ class Query(graphene.ObjectType):
documentations_by_course_id
=
FilterOrderList
(
DocumentationType
,
course_id
=
graphene
.
ID
(
required
=
True
)
)
documentations_for_coursebook
=
FilterOrderList
(
DocumentationType
,
course_id
=
graphene
.
ID
(
required
=
True
),
date_start
=
graphene
.
Date
(
required
=
True
),
date_end
=
graphene
.
Date
(
required
=
True
),
)
def
resolve_documentations_by_course_id
(
root
,
info
,
course_id
,
**
kwargs
):
documentations
=
Documentation
.
objects
.
filter
(
...
...
@@ -26,6 +33,13 @@ class Query(graphene.ObjectType):
)
return
documentations
def
resolve_documentations_for_coursebook
(
root
,
info
,
course_id
,
date_start
,
date_end
,
**
kwargs
):
datetime_start
=
datetime
.
combine
(
date_start
,
datetime
.
min
.
time
())
datetime_end
=
datetime
.
combine
(
date_end
,
datetime
.
max
.
time
())
# TODO: later on, allow getting documentations for other types than courses, e.g. groups or persons
return
Documentation
.
get_for_coursebook
(
"
COURSE
"
,
course_id
,
datetime_start
,
datetime_end
,
info
.
context
)
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