work on monitor

This commit is contained in:
jeffrey
2016-11-26 17:32:30 +01:00
parent 7e571a6794
commit aa1c21a8c8
38 changed files with 412 additions and 160 deletions

View File

@ -106,22 +106,30 @@ class Monitor(View,TemplateResponseMixin,LoginRequiredMixin):
station = stations.stations.filter(name = POST.get('station')) \
.first()
if not station:
return HttpResponse('')
station.prepare(fetch=True)
return Http404()
source = None
if 'source' in POST:
source = next([ s for s in station.sources
if s.name == POST['source']], None)
if station and action == 'skip':
if source:
source.skip()
else:
station.streamer.skip()
source = [ s for s in station.sources
if s.name == POST['source']]
source = source[0]
if not source:
return Http404
station.streamer.fetch()
source = source or station.streamer.current_source
if action == 'skip':
self.actionSkip(request, station, source)
if action == 'restart':
self.actionRestart(request, station, source)
return HttpResponse('')
def actionSkip(self, request, station, source):
source.skip()
def actionRestart(self, request, station, source):
source.restart()
class StatisticsView(View,TemplateResponseMixin,LoginRequiredMixin):
template_name = 'aircox/controllers/stats.html'