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
7e6747f2
Commit
7e6747f2
authored
10 months ago
by
permcu
Browse files
Options
Downloads
Patches
Plain Diff
Refactor get_documentations_for_person
& share between query & mutation.
parent
f98c1f41
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!361
Resolve "Add statistics page for absences"
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
aleksis/apps/alsijil/models.py
+27
-0
27 additions, 0 deletions
aleksis/apps/alsijil/models.py
aleksis/apps/alsijil/schema/__init__.py
+2
-11
2 additions, 11 deletions
aleksis/apps/alsijil/schema/__init__.py
aleksis/apps/alsijil/schema/absences.py
+2
-13
2 additions, 13 deletions
aleksis/apps/alsijil/schema/absences.py
with
31 additions
and
24 deletions
aleksis/apps/alsijil/models.py
+
27
−
0
View file @
7e6747f2
...
...
@@ -568,6 +568,33 @@ class Documentation(CalendarEvent):
return
(
docs
,
dummies
)
@classmethod
def
get_documentations_for_person
(
cls
,
person
:
int
,
start
:
datetime
,
end
:
datetime
,
incomplete
:
Optional
[
bool
]
=
False
,
)
->
tuple
:
"""
Get all the documentations for the person from start to end datetime.
Create dummy documentations if none exist.
Returns a tuple with a list of existing documentations and a list dummy documentations.
"""
event_params
=
{
"
type
"
:
"
PARTICIPANT
"
,
"
obj_id
"
:
PERSON_ID
,
}
events
=
LessonEvent
.
get_single_events
(
start
,
end
,
None
,
event_params
,
with_reference_object
=
True
,
)
return
Documentation
.
get_documentations_for_events
(
events
,
incomplete
)
class
ParticipationStatus
(
CalendarEvent
):
"""
A participation or absence record about a single person.
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/alsijil/schema/__init__.py
+
2
−
11
View file @
7e6747f2
...
...
@@ -157,21 +157,12 @@ class Query(graphene.ObjectType):
"""
lessons_for_person
=
[]
for
person
in
persons
:
event_params
=
{
"
type
"
:
"
PARTICIPANT
"
,
"
obj_id
"
:
PERSON_ID
,
}
events
=
LessonEvent
.
get_single_events
(
docs
,
dummies
=
Documentation
.
get_documentations_for_person
(
person
datetime
.
combine
(
start
,
datetime
.
min
.
time
()),
datetime
.
combine
(
end
,
datetime
.
max
.
time
()),
None
,
event_params
,
with_reference_object
=
True
,
)
docs
,
dummies
=
Documentation
.
get_documentations_for_events
(
events
)
lessons_for_person
.
append
(
id
=
person
,
lessons
=
docs
+
dummies
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/alsijil/schema/absences.py
+
2
−
13
View file @
7e6747f2
...
...
@@ -28,23 +28,12 @@ class AbsencesBatchCreateMutation(graphene.Mutation):
for
person
in
persons
:
# Get all documentations for this person between start & end
# Could be shared with query
event_params
=
{
"
type
"
:
"
PARTICIPANT
"
,
"
obj_id
"
:
PERSON_ID
,
}
events
=
LessonEvent
.
get_single_events
(
docs
,
dummies
=
Documentation
.
get_documentations_for_person
(
person
,
datetime
.
combine
(
start
,
datetime
.
min
.
time
()),
datetime
.
combine
(
end
,
datetime
.
max
.
time
()),
None
,
event_params
,
with_reference_object
=
True
,
)
docs
,
dummies
=
Documentation
.
get_documentations_for_events
(
events
)
# till here -> reuse?
# Create doc for dummies that are already in the past
future
=
false
for
dummy
in
dummies
:
...
...
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