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
baa6a974
Verified
Commit
baa6a974
authored
5 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Add short-hand for filtering lesson data by GET or POST query. Advances
#3
and
#34
.
parent
81195d3f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
biscuit/apps/chronos/models.py
+9
-0
9 additions, 0 deletions
biscuit/apps/chronos/models.py
biscuit/apps/chronos/views.py
+1
-6
1 addition, 6 deletions
biscuit/apps/chronos/views.py
with
10 additions
and
6 deletions
biscuit/apps/chronos/models.py
+
9
−
0
View file @
baa6a974
...
...
@@ -5,6 +5,7 @@ from django.core import validators
from
django.core.exceptions
import
ValidationError
from
django.db
import
models
from
django.db.models
import
Q
from
django.http.request
import
QueryDict
from
django.utils.translation
import
ugettext_lazy
as
_
from
biscuit.core.mixins
import
SchoolRelated
...
...
@@ -48,6 +49,14 @@ class LessonPeriodQuerySet(models.QuerySet):
return
self
.
filter
(
Q
(
substitutions__room__pk
=
room
,
substitutions__week
=
models
.
F
(
'
_week
'
))
|
Q
(
room__pk
=
room
))
def
filter_from_query
(
self
,
query_data
:
QueryDict
):
if
query_data
.
get
(
'
group
'
,
None
):
return
self
.
filter_group
(
int
(
query_data
[
'
group
'
]))
if
query_data
.
get
(
'
teacher
'
,
None
):
return
self
.
filter_teacher
(
int
(
query_data
[
'
teacher
'
]))
if
query_data
.
get
(
'
room
'
,
None
):
return
self
.
filter_room
(
int
(
query_data
[
'
room
'
]))
class
TimePeriod
(
SchoolRelated
):
WEEKDAY_CHOICES
=
[
...
...
This diff is collapsed.
Click to expand it.
biscuit/apps/chronos/views.py
+
1
−
6
View file @
baa6a974
...
...
@@ -33,12 +33,7 @@ def timetable(request: HttpRequest, year: Optional[int] = None, week: Optional[i
# Incrementally filter lesson periods by GET parameters
if
request
.
GET
.
get
(
'
group
'
,
None
)
or
request
.
GET
.
get
(
'
teacher
'
,
None
)
or
request
.
GET
.
get
(
'
room
'
,
None
):
if
'
group
'
in
request
.
GET
and
request
.
GET
[
'
group
'
]:
lesson_periods
=
lesson_periods
.
filter_group
(
int
(
request
.
GET
[
'
group
'
]))
if
'
teacher
'
in
request
.
GET
and
request
.
GET
[
'
teacher
'
]:
lesson_periods
=
lesson_periods
.
filter_teacher
(
int
(
request
.
GET
[
'
teacher
'
]))
if
'
room
'
in
request
.
GET
and
request
.
GET
[
'
room
'
]:
lesson_periods
=
lesson_periods
.
room_filter
(
int
(
request
.
GET
[
'
room
'
]))
lesson_periods
=
lesson_periods
.
filter_from_query
(
request
.
GET
)
else
:
# Redirect to a selected view if no filter provided
if
request
.
user
.
person
:
...
...
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