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
687857a8
Verified
Commit
687857a8
authored
5 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Merge get_prev_relevant_day to get_next_relevant_day by adding an extra attribute "prev"
parent
6648d720
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!31
Biscuit merge. Closes #53.
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/apps/chronos/util/prev_next.py
+13
-22
13 additions, 22 deletions
aleksis/apps/chronos/util/prev_next.py
aleksis/apps/chronos/views.py
+2
-2
2 additions, 2 deletions
aleksis/apps/chronos/views.py
with
15 additions
and
24 deletions
aleksis/apps/chronos/util/prev_next.py
+
13
−
22
View file @
687857a8
...
...
@@ -7,39 +7,30 @@ from django.utils import timezone
from
aleksis.apps.chronos.util.min_max
import
weekday_min_
,
weekday_max
,
time_max
def
get_next_relevant_day
(
day
:
Optional
[
date
]
=
None
,
time
:
Optional
[
time
]
=
None
)
->
date
:
"""
Returns next day with lessons depending on date and time
"""
def
get_next_relevant_day
(
day
:
Optional
[
date
]
=
None
,
time
:
Optional
[
time
]
=
None
,
prev
:
bool
=
False
)
->
date
:
"""
Returns next
(previous)
day with lessons depending on date and time
"""
if
day
is
None
:
day
=
timezone
.
now
().
date
()
if
time
is
not
None
:
if
time
is
not
None
and
not
prev
:
if
time
>
time_max
:
day
+=
timedelta
(
days
=
1
)
cw
=
CalendarWeek
.
from_date
(
day
)
if
day
.
weekday
()
>
weekday_max
:
cw
+=
1
day
=
cw
[
weekday_min_
]
if
prev
:
day
=
cw
[
weekday_max
]
else
:
cw
+=
1
day
=
cw
[
weekday_min_
]
elif
day
.
weekday
()
<
weekday_min_
:
day
=
cw
[
weekday_min_
]
if
prev
:
cw
-=
1
day
=
cw
[
weekday_max
]
else
:
day
=
cw
[
weekday_min_
]
return
day
def
get_prev_relevant_day
(
day
:
Optional
[
date
]
=
None
)
->
date
:
"""
Returns previous day with lessons depending on date
"""
if
day
is
None
:
day
=
timezone
.
now
().
date
()
cw
=
CalendarWeek
.
from_date
(
day
)
if
day
.
weekday
()
>
weekday_max
:
day
=
cw
[
weekday_max
]
elif
day
.
weekday
()
<
weekday_min_
:
cw
-=
1
day
=
cw
[
weekday_max
]
return
day
This diff is collapsed.
Click to expand it.
aleksis/apps/chronos/views.py
+
2
−
2
View file @
687857a8
...
...
@@ -23,14 +23,14 @@ from .util.min_max import (
weekday_min_
,
weekday_max
)
from
.util.prev_next
import
get_prev_relevant_day
,
get_next_relevant_day
from
.util.prev_next
import
get_next_relevant_day
from
.util.weeks
import
CalendarWeek
,
get_weeks_for_year
def
get_prev_next_by_day
(
day
:
date
,
url
:
str
)
->
Tuple
[
str
,
str
]:
"""
Build URLs for previous/next day
"""
day_prev
=
get_
prev
_relevant_day
(
day
-
timedelta
(
days
=
1
))
day_prev
=
get_
next
_relevant_day
(
day
-
timedelta
(
days
=
1
)
,
prev
=
True
)
day_next
=
get_next_relevant_day
(
day
+
timedelta
(
days
=
1
))
url_prev
=
reverse
(
url
,
args
=
[
day_prev
.
year
,
day_prev
.
month
,
day_prev
.
day
])
...
...
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