def __str__(self):
return ' - '.join(self.description) + ' - ' + str(self.datetime_start) + ' > ' + str(self.datetime_stop)
+ def to_dict(self):
+ dict = {'organization': self.organization.name,
+ 'department': self.department.name,
+ 'conference': self.conference.title,
+ 'professor': self.professor.name,
+ 'session': self.session.name,
+ 'comment': self.comment,
+ 'started': str(self.started),
+ }
+ return dict
+
@property
def description(self):
return [self.organization.name, self.conference.department.name, self.conference.title, self.session.name, self.professor.name, self.comment]
self.status = Status()
def index(self, request):
- status = self.get_status()
stations = Station.objects.filter(started=True)
- status = self.get_status()
+ status = self.get_server_status()
if stations or (status['writing'] or status['casting']):
template = 'telecaster/stop.html'
return render(request, template, {'station': station, 'status': status,
- 'hidden_fields': self.hidden_fields})
+ 'hidden_fields': self.hidden_fields, })
- @jsonrpc_method('telecaster.get_status')
- def get_status_json(request):
+ @jsonrpc_method('telecaster.get_server_status')
+ def get_server_status_json(request):
status = Status()
status.update()
return status.to_dict()
- def get_status(self):
+ def get_server_status(self):
status = Status()
status.update()
return status.to_dict()
-
+ @jsonrpc_method('telecaster.get_station_status')
+ def get_station_status_json(request):
+ stations = Station.objects.filter(started=True)
+ if stations:
+ station = stations[0].to_dict()
+ else:
+ station = {}
+ return station
+
class Status(object):
interfaces = ['eth0', 'eth1', 'eth2', 'eth0-eth2','eth3']