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
da3f326a
Verified
Commit
da3f326a
authored
5 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Add function to get lessons on date. Advances
#33
,
#34
.
parent
6c73fa33
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
biscuit/apps/chronos/models.py
+12
-2
12 additions, 2 deletions
biscuit/apps/chronos/models.py
biscuit/apps/chronos/views.py
+3
-9
3 additions, 9 deletions
biscuit/apps/chronos/views.py
with
15 additions
and
11 deletions
biscuit/apps/chronos/models.py
+
12
−
2
View file @
da3f326a
from
datetime
import
datetime
,
timedelta
from
datetime
import
date
,
datetime
,
timedelta
from
typing
import
Dict
,
Optional
,
Tuple
from
django.core
import
validators
...
...
@@ -10,7 +10,7 @@ from django.utils.translation import ugettext_lazy as _
from
biscuit.core.mixins
import
SchoolRelated
from
.util
import
CalendarWeek
from
.util
import
CalendarWeek
,
week_weekday_from_date
class
LessonPeriodManager
(
models
.
Manager
):
...
...
@@ -37,6 +37,16 @@ class LessonPeriodQuerySet(models.QuerySet):
select
=
{
'
_week
'
:
wanted_week
.
week
}
)
def
on_day
(
self
,
day
:
date
):
week
,
weekday
=
week_weekday_from_date
(
day
)
return
self
.
filter
(
lesson__date_start__lte
=
day
,
lesson__date_end__gte
=
day
,
period__weekday
=
weekday
).
extra
(
select
=
{
'
_week
'
:
week
.
week
}
)
def
filter_group
(
self
,
group
:
int
):
return
self
.
filter
(
Q
(
lesson__groups__pk
=
group
)
|
Q
(
lesson__groups__parent_groups__pk
=
group
))
...
...
This diff is collapsed.
Click to expand it.
biscuit/apps/chronos/views.py
+
3
−
9
View file @
da3f326a
...
...
@@ -16,7 +16,7 @@ from biscuit.core.util import messages
from
.forms
import
SelectForm
,
LessonSubstitutionForm
from
.models
import
LessonPeriod
,
TimePeriod
,
LessonSubstitution
from
.util
import
CalendarWeek
,
week_weekday_from_date
from
.util
import
CalendarWeek
from
.tables
import
LessonsTable
...
...
@@ -97,22 +97,16 @@ def lessons_day(request: HttpRequest, when: Optional[str] = None) -> HttpRespons
else
:
day
=
date
.
today
()
week
,
weekday
=
week_weekday_from_date
(
day
)
# Get lessons
lesson_periods
=
LessonPeriod
.
objects
.
filter
(
lesson__date_start__lte
=
day
,
lesson__date_end__gte
=
day
,
period__weekday
=
weekday
)
lesson_periods
=
LessonPeriod
.
objects
.
on_day
(
day
)
# Build table
lessons_table
=
LessonsTable
(
lesson_periods
.
extra
(
select
=
{
'
_week
'
:
week
.
week
}).
all
())
lessons_table
=
LessonsTable
(
lesson_periods
.
all
())
RequestConfig
(
request
).
configure
(
lessons_table
)
context
[
'
current_head
'
]
=
_
(
'
Lessons %s
'
)
%
(
day
)
context
[
'
lessons_table
'
]
=
lessons_table
context
[
'
day
'
]
=
day
context
[
'
week
'
]
=
week
context
[
'
lesson_periods
'
]
=
lesson_periods
day_prev
=
day
-
timedelta
(
days
=
1
)
...
...
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