Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Lesrooster
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
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®
Onboarding
AlekSIS-App-Lesrooster
Commits
fc1a3826
Verified
Commit
fc1a3826
authored
4 months ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Fix PDF export
parent
668c111b
No related branches found
Branches containing commit
No related tags found
1 merge request
!36
Draft: Resolve "[New data model] PDF export for "regular" timetable"
Pipeline
#194805
failed
2 months ago
Stage: prepare
Stage: test
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/apps/lesrooster/managers.py
+6
-6
6 additions, 6 deletions
aleksis/apps/lesrooster/managers.py
aleksis/apps/lesrooster/util/build.py
+8
-35
8 additions, 35 deletions
aleksis/apps/lesrooster/util/build.py
with
14 additions
and
41 deletions
aleksis/apps/lesrooster/managers.py
+
6
−
6
View file @
fc1a3826
...
...
@@ -127,7 +127,7 @@ class LessonQuerySet(QuerySet):
self
,
type_
:
TimetableType
,
obj
:
Union
[
Person
,
Group
,
Room
,
int
],
)
->
Optional
[
"
LessonQuerySet
"
]
:
)
->
"
LessonQuerySet
"
:
"""
Filter lessons for a group, teacher or room by provided type.
"""
if
type_
==
TimetableType
.
GROUP
:
return
self
.
filter_group
(
obj
)
...
...
@@ -136,9 +136,9 @@ class LessonQuerySet(QuerySet):
elif
type_
==
TimetableType
.
ROOM
:
return
self
.
filter_room
(
obj
)
else
:
return
N
one
return
self
.
n
one
()
def
filter_from_person
(
self
,
person
:
Person
)
->
Optional
[
"
LessonQuerySet
"
]
:
def
filter_from_person
(
self
,
person
:
Person
)
->
"
LessonQuerySet
"
:
"""
Filter lessons for a person.
"""
type_
=
person
.
timetable_type
...
...
@@ -147,7 +147,7 @@ class LessonQuerySet(QuerySet):
elif
type_
==
TimetableType
.
GROUP
:
return
self
.
filter_participant
(
person
)
else
:
return
N
one
return
self
.
n
one
()
class
LessonManager
(
AlekSISBaseManagerWithoutMigrations
):
...
...
@@ -167,14 +167,14 @@ class SupervisionQuerySet(QuerySet):
self
,
type_
:
TimetableType
,
obj
:
Union
[
Person
,
Group
,
Room
,
int
],
)
->
Optional
[
"
SupervisionQuerySet
"
]
:
)
->
"
SupervisionQuerySet
"
:
"""
Filter supervisions for a eacher or room by provided type.
"""
if
type_
==
TimetableType
.
TEACHER
:
return
self
.
filter_teacher
(
obj
)
elif
type_
==
TimetableType
.
ROOM
:
return
self
.
filter_room
(
obj
)
else
:
return
N
one
return
self
.
n
one
()
def
filter_from_person
(
self
,
person
:
Person
)
->
Optional
[
"
SupervisionQuerySet
"
]:
"""
Filter supervisions for a person.
"""
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/lesrooster/util/build.py
+
8
−
35
View file @
fc1a3826
...
...
@@ -8,18 +8,10 @@ from aleksis.core.models import Group, Person, Room
def
build_timetable
(
time_grid
:
TimeGrid
,
type_
:
Union
[
TimetableType
,
str
],
type_
:
TimetableType
,
obj
:
Union
[
Group
,
Room
,
Person
],
)
->
list
|
None
:
"""
Build regular timetable for the given time grid.
"""
is_person
=
False
if
type_
==
"
person
"
:
is_person
=
True
type_
=
obj
.
timetable_type
if
type_
is
None
:
return
None
slots
=
Slot
.
objects
.
filter
(
time_grid
=
time_grid
).
order_by
(
"
weekday
"
,
"
time_start
"
)
lesson_periods_per_slot
=
OrderedDict
()
supervisions_per_slot
=
OrderedDict
()
...
...
@@ -33,37 +25,19 @@ def build_timetable(
max_slots
=
len
(
max_slots
)
# Get matching lessons
lessons
=
Lesson
.
objects
.
filter
(
slot_start__time_grid
=
time_grid
)
lessons
=
(
lessons
.
filter_from_person
(
obj
)
if
is_person
else
lessons
.
filter_from_group
(
type_
,
obj
)
)
lessons
=
Lesson
.
objects
.
filter
(
slot_start__time_grid
=
time_grid
).
filter_from_type
(
type_
,
obj
)
# Sort lesson periods in a dict
for
lesson
in
lessons
:
for
slot
in
Slot
.
objects
.
filter
(
time_grid
=
time_grid
,
weekday
=
lesson
.
slot_start
.
weekday
,
time_start__gte
=
lesson
.
slot_start
.
time_start
,
time_end__lte
=
lesson
.
slot_end
.
time_end
,
).
not_instance_of
(
BreakSlot
):
lesson_periods_per_slot
[
slot
].
append
(
lesson
)
lesson_periods_per_slot
[
lesson
.
slot_start
].
append
(
lesson
)
# Get matching supervisions
needed_break_slots
=
[]
supervisions
=
Supervision
.
objects
.
filter
(
break_slot__time_grid
=
time_grid
).
all
()
if
is_person
:
supervisions
=
supervisions
.
filter_from_person
(
obj
)
else
:
supervisions
=
supervisions
.
filter_from_type
(
type_
,
obj
)
if
supervisions
:
for
supervision
in
supervisions
:
if
supervision
.
break_slot
not
in
needed_break_slots
:
needed_break_slots
.
append
(
supervision
.
break_slot
)
supervisions
=
Supervision
.
objects
.
filter
(
break_slot__time_grid
=
time_grid
).
filter_from_type
(
type_
,
obj
)
supervisions_per_slot
[
supervision
.
break_slot
]
=
supervision
for
supervision
in
supervisions
:
supervisions_per_slot
[
supervision
.
break_slot
]
=
supervision
rows
=
[]
for
slot_idx
in
range
(
max_slots
):
# period is period after break
...
...
@@ -100,7 +74,6 @@ def build_timetable(
cols
.
append
(
col
)
row
[
"
cols
"
]
=
cols
rows
.
append
(
row
)
return
rows
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