Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
radiopanik
django-panik-nonstop
Commits
418f1d40
Commit
418f1d40
authored
May 21, 2020
by
fred
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add switch to compute-durations to handle jingles
parent
d54df015
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
4 deletions
+23
-4
nonstop/management/commands/compute_durations.py
nonstop/management/commands/compute_durations.py
+10
-4
nonstop/models.py
nonstop/models.py
+13
-0
No files found.
nonstop/management/commands/compute_durations.py
View file @
418f1d40
...
...
@@ -4,7 +4,7 @@ import os
from
django.core.management.base
import
BaseCommand
from
emissions.utils
import
get_duration
from
...models
import
Track
from
...models
import
Track
,
Jingle
class
Command
(
BaseCommand
):
...
...
@@ -12,16 +12,22 @@ class Command(BaseCommand):
parser
.
add_argument
(
'--recent'
,
action
=
'store_true'
,
default
=
False
,
help
=
'Only do recent files'
)
parser
.
add_argument
(
'--jingles'
,
action
=
'store_true'
,
default
=
False
,
help
=
'Do jingles'
)
parser
.
add_argument
(
'--force'
,
action
=
'store_true'
,
default
=
False
,
help
=
'Recompute existing durations'
)
def
handle
(
self
,
verbosity
,
**
kwargs
):
qs
=
Track
.
objects
.
all
()
if
kwargs
.
get
(
'jingles'
):
qs
=
Jingle
.
objects
.
all
()
else
:
qs
=
Track
.
objects
.
all
()
if
kwargs
.
get
(
'recent'
):
qs
=
qs
.
filter
(
creation_timestamp__gt
=
datetime
.
date
.
today
()
-
datetime
.
timedelta
(
days
=
10
))
if
not
kwargs
.
get
(
'force'
):
qs
=
qs
.
filter
(
duration__isnull
=
True
)
if
kwargs
.
get
(
'recent'
):
qs
=
qs
.
filter
(
creation_timestamp__gt
=
datetime
.
date
.
today
()
-
datetime
.
timedelta
(
days
=
10
))
if
verbosity
:
total
=
qs
.
count
()
for
i
,
track
in
enumerate
(
qs
):
...
...
nonstop/models.py
View file @
418f1d40
...
...
@@ -182,6 +182,19 @@ class Jingle(models.Model):
Jingle
.
objects
.
all
().
update
(
**
{
attr
:
False
})
return
super
(
Jingle
,
self
).
save
(
**
kwargs
)
@
property
def
short
(
self
):
return
self
.
filepath
[
len
(
REMOTE_BASE_PATH
):]
def
file_path
(
self
):
# for compatibility with Track model method
return
self
.
get_local_filepath
()
def
get_local_filepath
(
self
):
if
not
self
.
short
:
return
None
return
os
.
path
.
join
(
LOCAL_BASE_PATH
,
self
.
short
)
@
property
def
title
(
self
):
return
self
.
label
...
...
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