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
eceac485
Verified
Commit
eceac485
authored
4 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Rewrite filter_group to select lessons only one time
parent
0ad7e1d0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!45
Improve handling of child/parent groups
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/apps/chronos/models.py
+11
-4
11 additions, 4 deletions
aleksis/apps/chronos/models.py
with
11 additions
and
4 deletions
aleksis/apps/chronos/models.py
+
11
−
4
View file @
eceac485
...
@@ -127,10 +127,17 @@ class LessonDataQuerySet(models.QuerySet):
...
@@ -127,10 +127,17 @@ class LessonDataQuerySet(models.QuerySet):
def
filter_group
(
self
,
group
:
Union
[
Group
,
int
]):
def
filter_group
(
self
,
group
:
Union
[
Group
,
int
]):
"""
Filter for all lessons a group (class) regularly attends.
"""
"""
Filter for all lessons a group (class) regularly attends.
"""
return
self
.
filter
(
if
isinstance
(
group
,
int
):
Q
(
**
{
self
.
_period_path
+
"
lesson__groups
"
:
group
})
group
=
Group
.
objects
.
get
(
pk
=
group
)
|
Q
(
**
{
self
.
_period_path
+
"
lesson__groups__parent_groups
"
:
group
})
)
if
group
.
parent_groups
:
# Prevent to show lessons multiple times
return
self
.
filter
(
Q
(
**
{
self
.
_period_path
+
"
lesson__groups
"
:
group
}))
else
:
return
self
.
filter
(
Q
(
**
{
self
.
_period_path
+
"
lesson__groups
"
:
group
})
|
Q
(
**
{
self
.
_period_path
+
"
lesson__groups__parent_groups
"
:
group
})
)
def
filter_teacher
(
self
,
teacher
:
Union
[
Person
,
int
]):
def
filter_teacher
(
self
,
teacher
:
Union
[
Person
,
int
]):
"""
Filter for all lessons given by a certain teacher.
"""
"""
Filter for all lessons given by a certain teacher.
"""
...
...
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