Commit 5d8f3473 authored by fred's avatar fred
Browse files

add nonstop info to whatsonair command

parent 1792d621
...@@ -8,3 +8,4 @@ class Command(BaseCommand): ...@@ -8,3 +8,4 @@ class Command(BaseCommand):
onair = whatsonair() onair = whatsonair()
print 'found episode:', onair.get('episode') print 'found episode:', onair.get('episode')
print 'found emission:', onair.get('emission') print 'found emission:', onair.get('emission')
print 'found nonstop:', onair.get('nonstop')
...@@ -16,7 +16,7 @@ def maybe_resize(image_path): ...@@ -16,7 +16,7 @@ def maybe_resize(image_path):
def whatsonair(): def whatsonair():
from models import Diffusion, Schedule from models import Diffusion, Schedule, Nonstop
now = datetime.now() now = datetime.now()
program = day_program(now) program = day_program(now)
...@@ -24,6 +24,7 @@ def whatsonair(): ...@@ -24,6 +24,7 @@ def whatsonair():
emission = None emission = None
episode = None episode = None
nonstop = None
current_slot = None current_slot = None
if program and program[-1].datetime + timedelta(minutes=program[-1].get_duration()) > now: if program and program[-1].datetime + timedelta(minutes=program[-1].get_duration()) > now:
current_slot = program[-1] current_slot = program[-1]
...@@ -33,10 +34,19 @@ def whatsonair(): ...@@ -33,10 +34,19 @@ def whatsonair():
episode = current_slot.episode episode = current_slot.episode
emission = episode.emission emission = episode.emission
else: else:
pass for nonstop in Nonstop.objects.all():
if (nonstop.start < nonstop.end and (
now.time() >= nonstop.start and now.time() < nonstop.end)) or \
(nonstop.start > nonstop.end and (
now.time() >= nonstop.start or now.time() < nonstop.end)):
current_slot = nonstop
break
else:
nonstop = None
return {'emission': emission, return {'emission': emission,
'episode': episode, 'episode': episode,
'nonstop': nonstop,
'current_slot': current_slot} 'current_slot': current_slot}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment