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
135db922
Verified
Commit
135db922
authored
5 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Allow passing either object or int to filter methods. Advances
#33
,
#34
.
parent
da3f326a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
biscuit/apps/chronos/models.py
+10
-7
10 additions, 7 deletions
biscuit/apps/chronos/models.py
with
10 additions
and
7 deletions
biscuit/apps/chronos/models.py
+
10
−
7
View file @
135db922
from
__future__
import
annotations
from
datetime
import
date
,
datetime
,
timedelta
from
typing
import
Dict
,
Optional
,
Tuple
from
typing
import
Dict
,
Optional
,
Tuple
,
Union
from
django.core
import
validators
from
django.core.exceptions
import
ValidationError
...
...
@@ -9,6 +11,7 @@ from django.http.request import QueryDict
from
django.utils.translation
import
ugettext_lazy
as
_
from
biscuit.core.mixins
import
SchoolRelated
from
biscuit.core.models
import
Group
,
Person
from
.util
import
CalendarWeek
,
week_weekday_from_date
...
...
@@ -47,17 +50,17 @@ class LessonPeriodQuerySet(models.QuerySet):
select
=
{
'
_week
'
:
week
.
week
}
)
def
filter_group
(
self
,
group
:
int
):
def
filter_group
(
self
,
group
:
Union
[
Group
,
int
]
):
return
self
.
filter
(
Q
(
lesson__groups
__pk
=
group
)
|
Q
(
lesson__groups__parent_groups
__pk
=
group
))
Q
(
lesson__groups
=
group
)
|
Q
(
lesson__groups__parent_groups
=
group
))
def
filter_teacher
(
self
,
teacher
:
int
):
def
filter_teacher
(
self
,
teacher
:
Union
[
Person
,
int
]
):
return
self
.
filter
(
Q
(
substitutions__teachers
__pk
=
teacher
,
substitutions__week
=
models
.
F
(
'
_week
'
))
|
Q
(
lesson__teachers
__pk
=
teacher
))
Q
(
substitutions__teachers
=
teacher
,
substitutions__week
=
models
.
F
(
'
_week
'
))
|
Q
(
lesson__teachers
=
teacher
))
def
filter_room
(
self
,
room
:
int
):
def
filter_room
(
self
,
room
:
Union
[
Room
,
int
]
):
return
self
.
filter
(
Q
(
substitutions__room
__pk
=
room
,
substitutions__week
=
models
.
F
(
'
_week
'
))
|
Q
(
room
__pk
=
room
))
Q
(
substitutions__room
=
room
,
substitutions__week
=
models
.
F
(
'
_week
'
))
|
Q
(
room
=
room
))
def
filter_from_query
(
self
,
query_data
:
QueryDict
):
if
query_data
.
get
(
'
group
'
,
None
):
...
...
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