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
Incidents
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
76bde5ff
Commit
76bde5ff
authored
Mar 29, 2020
by
fred
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prefill new episode with duration from schedule (instead of default)
parent
ecd8c4dc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
3 deletions
+12
-3
emissions/models.py
emissions/models.py
+11
-2
emissions/views.py
emissions/views.py
+1
-1
No files found.
emissions/models.py
View file @
76bde5ff
...
...
@@ -178,7 +178,7 @@ class Emission(models.Model):
def
get_sorted_newsitems
(
self
):
return
self
.
newsitem_set
.
select_related
().
order_by
(
'-date'
)
def
get_next_planned_date
(
self
,
since
=
None
):
def
get_next_planned_date
_and_schedule
(
self
,
since
=
None
):
schedules
=
self
.
schedule_set
.
filter
(
rerun
=
False
)
if
not
schedules
:
return
None
...
...
@@ -186,10 +186,19 @@ class Emission(models.Model):
since
=
datetime
.
datetime
.
today
()
possible_dates
=
[]
for
schedule
in
schedules
:
possible_dates
.
append
(
schedule
.
get_next_planned_date
(
sinc
e
))
possible_dates
.
append
(
(
schedule
.
get_next_planned_date
(
since
),
schedul
e
))
possible_dates
.
sort
()
return
possible_dates
[
0
]
def
get_next_planned_date
(
self
,
since
=
None
):
result
=
self
.
get_next_planned_date_and_schedule
(
since
=
since
)
return
result
[
0
]
if
result
else
None
def
get_next_planned_duration
(
self
,
since
=
None
):
result
=
self
.
get_next_planned_date_and_schedule
(
since
=
since
)
if
not
result
:
return
None
return
result
[
1
].
duration
or
self
.
duration
@
python_2_unicode_compatible
class
Schedule
(
models
.
Model
,
WeekdayMixin
):
...
...
emissions/views.py
View file @
76bde5ff
...
...
@@ -176,7 +176,7 @@ class EpisodeCreateView(CreateView):
def
get_initial
(
self
):
initial
=
super
(
EpisodeCreateView
,
self
).
get_initial
()
initial
[
'emission'
]
=
Emission
.
objects
.
get
(
slug
=
self
.
kwargs
.
get
(
'emission_slug'
))
initial
[
'duration'
]
=
initial
[
'emission'
].
duration
initial
[
'duration'
]
=
initial
[
'emission'
].
get_next_planned_duration
()
initial
[
'first_diffusion'
]
=
initial
[
'emission'
].
get_next_planned_date
()
for
i
,
schedule
in
enumerate
(
Schedule
.
objects
.
filter
(
emission
=
initial
[
'emission'
],
...
...
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