summaryrefslogtreecommitdiff
path: root/nop
diff options
context:
space:
mode:
authorErnesto Rico-Schmidt <e.rico.schmidt@gmail.com>2014-04-29 22:22:00 (GMT)
committerErnesto Rico-Schmidt <e.rico.schmidt@gmail.com>2014-04-29 22:22:00 (GMT)
commitac251a798769bc5909d25a1f95a98822d46bfbb8 (patch)
tree46e3753599dbe8e02d6299a557ba707bedbd3acc /nop
parent185a79985c93c44e058ab4bf0345d2dafc4148ee (diff)
pep8-ized code
Diffstat (limited to 'nop')
-rw-r--r--nop/models.py1
-rw-r--r--nop/urls.py6
-rw-r--r--nop/views.py15
3 files changed, 15 insertions, 7 deletions
diff --git a/nop/models.py b/nop/models.py
index 6aeb794..1b39eed 100644
--- a/nop/models.py
+++ b/nop/models.py
@@ -30,6 +30,7 @@ class Standby(models.Model):
db_table = u'standby'
ordering = ['-timestamp']
+
class State(models.Model):
timestamp = models.BigIntegerField(primary_key=True)
state = models.CharField(max_length=96, blank=True)
diff --git a/nop/urls.py b/nop/urls.py
index c4012a6..0d7f279 100644
--- a/nop/urls.py
+++ b/nop/urls.py
@@ -8,7 +8,9 @@ NOP_STATIC_DIR = os.path.join(os.path.dirname(__file__), 'site_media')
urlpatterns = patterns(
'',
url(r'^/get_current/?$', get_current),
- url(r'^/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/(?P<hour>\d{1,2})/(?P<minute>\d{1,2})/?$', get),
+ url(r'^/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/(?P<hour>\d{1,2})/(?P<minute>\d{1,2})/?$',
+ get),
url(r'^/?$', nop_form),
- url(r'^/static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': NOP_STATIC_DIR}),
+ url(r'^/static/(?P<path>.*)$', 'django.views.static.serve',
+ {'document_root': NOP_STATIC_DIR}),
)
diff --git a/nop/views.py b/nop/views.py
index 9d71379..967a81c 100644
--- a/nop/views.py
+++ b/nop/views.py
@@ -59,7 +59,8 @@ def _which(timestamp=None):
def _get_show(datetime=None):
try:
if datetime:
- timeslot = TimeSlot.objects.get(start__lte=datetime, end__gt=datetime)
+ timeslot = TimeSlot.objects.get(start__lte=datetime,
+ end__gt=datetime)
else:
timeslot = TimeSlot.objects.get_or_create_current()
except (ObjectDoesNotExist, MultipleObjectsReturned):
@@ -82,7 +83,8 @@ def _current():
album = None
show = _get_show()
- if show['id'] in MUSIKPROG_IDS or (show['id'] in SPECIAL_PROGRAM_IDS and not show['note']):
+ if show['id'] in MUSIKPROG_IDS \
+ or (show['id'] in SPECIAL_PROGRAM_IDS and not show['note']):
result = _which().objects.using(DB).all()[0]
artist = result.artist
title = result.title
@@ -105,7 +107,8 @@ def _bydate(year=None, month=None, day=None, hour=None, minute=None):
'title': None,
'album': None}]
else:
- ts = int(time.mktime((int(year), int(month), int(day), int(hour), int(minute), 0, 0, 0, -1))) * 1000000
+ ts = int(time.mktime((int(year), int(month), int(day), int(hour),
+ int(minute), 0, 0, 0, -1))) * 1000000
result = _which(ts).objects.using(DB).filter(timestamp__lt=ts)[:5]
return [{'show': show['name'],
'start': _dtstring(time.localtime(item.timestamp//1000000)),
@@ -129,14 +132,16 @@ def nop_form(request):
date = None
time = None
- if request.method == 'GET' and ('date' in request.GET or 'time' in request.GET):
+ if request.method == 'GET' \
+ and ('date' in request.GET or 'time' in request.GET):
form = NopForm(request.GET)
if form.is_valid():
date = form.cleaned_data['date']
time = form.cleaned_data['time']
else:
- form = NopForm(initial={'date': datetime.date(datetime.now()), 'time': datetime.time(datetime.now())})
+ form = NopForm(initial={'date': datetime.date(datetime.now()),
+ 'time': datetime.time(datetime.now())})
if not date:
date = datetime.date(datetime.now())