Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
django-panik-emissions
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
radiopanik
django-panik-emissions
Commits
1f781797
Commit
1f781797
authored
Oct 21, 2020
by
fred
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adjust time of dawn
parent
36330815
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
7 deletions
+9
-7
emissions/models.py
emissions/models.py
+7
-5
emissions/utils.py
emissions/utils.py
+2
-2
No files found.
emissions/models.py
View file @
1f781797
...
...
@@ -40,22 +40,24 @@ PODCAST_SOUND_QUALITY_LIST = (
class
WeekdayMixin
(
object
):
DAY_HOUR_START
=
5
DAY_HOUR_START
=
4
DAY_MINUTE_START
=
30
def
get_weekday
(
self
):
weekday
=
self
.
datetime
.
weekday
()
+
7
if
self
.
datetime
.
time
()
<
datetime
.
time
(
self
.
DAY_HOUR_START
,
0
):
if
self
.
datetime
.
time
()
<
datetime
.
time
(
self
.
DAY_HOUR_START
,
self
.
DAY_MINUTE_START
):
weekday
-=
1
weekday
%=
7
return
weekday
def
is_on_weekday
(
self
,
day
):
# day is [1..7]
week_day
=
self
.
datetime
.
weekday
()
if
self
.
datetime
.
hour
<
self
.
DAY_HOUR_START
:
if
(
self
.
datetime
.
hour
,
self
.
datetime
.
minute
)
<
(
self
.
DAY_HOUR_START
,
self
.
DAY_MINUTE_START
)
:
week_day
-=
1
week_day
=
(
week_day
%
7
)
+
1
if
hasattr
(
self
,
'episode'
):
if
self
.
datetime
.
hour
<
self
.
DAY_HOUR_START
and
self
.
end_datetime
.
hour
>
self
.
DAY_HOUR_START
:
if
(
self
.
datetime
.
hour
,
self
.
datetime
.
minute
)
<
(
self
.
DAY_HOUR_START
,
self
.
DAY_MINUTE_START
)
and
\
(
self
.
end_datetime
.
hour
,
self
.
end_datetime
.
minute
)
>=
(
self
.
DAY_HOUR_START
,
self
.
DAY_MINUTE_START
):
if
(
self
.
end_datetime
.
weekday
()
+
1
)
==
day
:
return
True
return
week_day
==
day
...
...
@@ -287,7 +289,7 @@ class Schedule(models.Model, WeekdayMixin):
def
matches
(
self
,
dt
):
weekday
=
dt
.
weekday
()
if
dt
.
hour
<
self
.
DAY_HOUR_START
:
if
(
dt
.
hour
,
dt
.
minute
)
<
(
self
.
DAY_HOUR_START
,
self
.
DAY_MINUTE_START
)
:
weekday
-=
1
if
weekday
!=
self
.
get_weekday
():
return
False
...
...
emissions/utils.py
View file @
1f781797
...
...
@@ -56,7 +56,7 @@ def whatsonair():
now
=
datetime
.
now
()
# get program of today minus a few hours, as radio days are not from
# midnight to midnigth but from 5am to 5am
program
=
day_program
(
now
-
timedelta
(
hours
=
Schedule
.
DAY_HOUR_START
),
program
=
day_program
(
now
-
timedelta
(
hours
=
Schedule
.
DAY_HOUR_START
)
+
timedelta
(
minutes
=
Schedule
.
DAY_MINUTE_START
)
,
prefetch_sounds
=
False
,
prefetch_categories
=
False
,
include_nonstop
=
False
)
program
=
[
x
for
x
in
program
if
not
x
.
datetime
>
now
]
...
...
@@ -220,7 +220,7 @@ def period_program(date_start, date_end, prefetch_sounds=True,
# last step is adding nonstop zones between slots
nonstops
=
list
(
Nonstop
.
objects
.
all
().
order_by
(
'start'
))
nonstops
=
[
x
for
x
in
nonstops
if
x
.
start
!=
x
.
end
]
dawn
=
time
(
Schedule
.
DAY_HOUR_START
,
0
)
dawn
=
time
(
Schedule
.
DAY_HOUR_START
,
Schedule
.
DAY_MINUTE_START
)
try
:
first_of_the_day
=
[
x
for
x
in
nonstops
if
x
.
start
<=
dawn
][
-
1
]
nonstops
=
nonstops
[
nonstops
.
index
(
first_of_the_day
):]
+
nonstops
[:
nonstops
.
index
(
first_of_the_day
)]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment