Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Chronos
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-Chronos
Commits
949bb6fb
Verified
Commit
949bb6fb
authored
4 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Add little improvements and bug fixes to custom query methods
parent
a10cd6ec
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!47
Advanced data in timetable views
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/apps/chronos/models.py
+14
-11
14 additions, 11 deletions
aleksis/apps/chronos/models.py
with
14 additions
and
11 deletions
aleksis/apps/chronos/models.py
+
14
−
11
View file @
949bb6fb
...
...
@@ -143,18 +143,18 @@ class LessonDataQuerySet(models.QuerySet):
def
filter_teacher
(
self
,
teacher
:
Union
[
Person
,
int
]):
"""
Filter for all lessons given by a certain teacher.
"""
return
self
.
filter
(
Q
(
**
{
self
.
_subst_path
+
"
teachers
"
:
teacher
,
self
.
_subst_path
+
"
week
"
:
F
(
"
_week
"
),})
|
Q
(
**
{
self
.
_period_path
+
"
lesson__teachers
"
:
teacher
})
)
qs1
=
self
.
filter
(
**
{
self
.
_period_path
+
"
lesson__teachers
"
:
teacher
})
qs2
=
self
.
filter
(
**
{
self
.
_subst_path
+
"
teachers
"
:
teacher
,
self
.
_subst_path
+
"
week
"
:
F
(
"
_week
"
),
})
return
qs1
.
union
(
qs2
)
def
filter_room
(
self
,
room
:
Union
[
Room
,
int
]):
"""
Filter for all lessons taking part in a certain room.
"""
return
self
.
filter
(
Q
(
**
{
self
.
_subst_path
+
"
room
"
:
room
,
self
.
_subst_path
+
"
week
"
:
F
(
"
_week
"
),})
|
Q
(
**
{
self
.
_period_path
+
"
room
"
:
room
})
)
qs1
=
self
.
filter
(
**
{
self
.
_period_path
+
"
room
"
:
room
})
qs2
=
self
.
filter
(
**
{
self
.
_subst_path
+
"
room
"
:
room
,
self
.
_subst_path
+
"
week
"
:
F
(
"
_week
"
),})
return
qs1
.
union
(
qs2
)
def
annotate_week
(
self
,
week
:
Union
[
CalendarWeek
,
int
]):
"""
Annotate all lessons in the QuerySet with the number of the provided calendar week.
"""
...
...
@@ -227,7 +227,7 @@ class LessonPeriodQuerySet(LessonDataQuerySet):
elif
type_
==
"
group
"
:
# Student
return
person
.
lesson_periods_as_participant
return
self
.
filter
(
lesson__groups__members
=
person
)
else
:
# If no student or teacher
...
...
@@ -237,7 +237,7 @@ class LessonPeriodQuerySet(LessonDataQuerySet):
if
person
.
timetable_type
is
None
:
return
None
lesson_periods
=
LessonPeriod
.
objects
.
on_day
(
wanted_day
).
filter_from_person
(
person
)
lesson_periods
=
self
.
on_day
(
wanted_day
).
filter_from_person
(
person
)
return
lesson_periods
...
...
@@ -765,7 +765,10 @@ class SupervisionQuerySet(models.QuerySet):
"""
Filter for all supervisions given by a certain teacher.
"""
if
self
.
count
()
>
0
:
week
=
CalendarWeek
(
week
=
self
[
0
].
_week
)
if
hasattr
(
self
[
0
],
"
_week
"
):
week
=
CalendarWeek
(
week
=
self
[
0
].
_week
)
else
:
week
=
CalendarWeek
.
current_week
()
dates
=
[
week
[
w
]
for
w
in
range
(
0
,
7
)]
...
...
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