summaryrefslogtreecommitdiff
path: root/nop
diff options
context:
space:
mode:
authorJohannes Raggam <raggam-nl@adm.at>2011-12-02 09:40:16 (GMT)
committerJohannes Raggam <raggam-nl@adm.at>2011-12-02 09:40:16 (GMT)
commit0af80555fb9c00d59d45aa4e69c3cb3e80e5c2cd (patch)
tree30472797063bfb9081afd0e83fee2d1d80e8d720 /nop
parent40fa04b435278b440db3696e58a645ab83871fdd (diff)
formatting
Diffstat (limited to 'nop')
-rw-r--r--nop/views.py54
1 files changed, 22 insertions, 32 deletions
diff --git a/nop/views.py b/nop/views.py
index bfb9157..4759cdc 100644
--- a/nop/views.py
+++ b/nop/views.py
@@ -86,49 +86,39 @@ def _current():
'album': album}
def _bydate(year=None, month=None, day=None, hour=None, minute=None):
- #try:
- #import pdb;pdb.set_trace()
- show = _get_show(datetime(year, month, day, hour, minute))
- if show['id'] and show['id'] not in MUSIKPROG_IDS:
- return [{'show': show['name'],
- 'start': show['start'],
- 'artist': None,
- 'title': None,
- 'album': None}]
- else:
- # tm_year,tm_mon,tm_mday,tm_hour,tm_min,tm_sec,tm_wday,tm_yday,tm_isdst
- 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)),
- 'artist': item.artist,
- 'title': item.title,
- 'album': item.album} for item in result]
- #except: # all errors
- # return None
-
+ show = _get_show(datetime(year, month, day, hour, minute))
+ if show['id'] and show['id'] not in MUSIKPROG_IDS:
+ return [{'show': show['name'],
+ 'start': show['start'],
+ 'artist': None,
+ 'title': None,
+ 'album': None}]
+ else:
+ # tm_year,tm_mon,tm_mday,tm_hour,tm_min,tm_sec,tm_wday,tm_yday,tm_isdst
+ 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)),
+ 'artist': item.artist,
+ 'title': item.title,
+ 'album': item.album} for item in result]
def get_current(request):
response = json.dumps(_current())
-
return HttpResponse(response, mimetype='application/json')
- #return HttpResponse(response, mimetype='text/plain')
def get(request, year=None, month=None, day=None, hour=None, minute=None):
response = json.dumps(_bydate(year, month, day, hour, minute))
-
return HttpResponse(response, mimetype='application/json')
- #return HttpResponse(response, mimetype='text/plain')
-
def nop_form(request):
context = {}
- # currently no csrf security for nicier forms
+ ## currently no csrf security for nicier forms
#context.update(csrf(request)) # in django template: {% csrf_token %}
date = None
time = None