Commit 5d8f3473 authored by fred's avatar fred

add nonstop info to whatsonair command

parent 1792d621
......@@ -8,3 +8,4 @@ class Command(BaseCommand):
onair = whatsonair()
print 'found episode:', onair.get('episode')
print 'found emission:', onair.get('emission')
print 'found nonstop:', onair.get('nonstop')
......@@ -16,7 +16,7 @@ def maybe_resize(image_path):
def whatsonair():
from models import Diffusion, Schedule
from models import Diffusion, Schedule, Nonstop
now = datetime.now()
program = day_program(now)
......@@ -24,6 +24,7 @@ def whatsonair():
emission = None
episode = None
nonstop = None
current_slot = None
if program and program[-1].datetime + timedelta(minutes=program[-1].get_duration()) > now:
current_slot = program[-1]
......@@ -33,10 +34,19 @@ def whatsonair():
episode = current_slot.episode
emission = episode.emission
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,
'episode': episode,
'nonstop': nonstop,
'current_slot': current_slot}
......
Markdown is supported
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