]> git.parisson.com Git - telecaster-client.git/commitdiff
fix station json method
authoryomguy <yomguy@parisson.com>
Thu, 30 Jun 2011 13:02:50 +0000 (15:02 +0200)
committeryomguy <yomguy@parisson.com>
Thu, 30 Jun 2011 13:02:50 +0000 (15:02 +0200)
telecaster/models.py
telecaster/views.py

index 190a09db7c21a5480e4f443d7a752af68debc280..3445ba6f6faa6db78ee93b14b8812898135a6523 100644 (file)
@@ -135,6 +135,17 @@ class Station(Model):
     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]
index f59eabf4f2b52363ce21a1951ad9f0daff5645c9..0aab94112ffbefd6e7579e1d5193c1bd9e5df89b 100644 (file)
@@ -56,9 +56,8 @@ class WebView(object):
         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'
@@ -90,21 +89,29 @@ class WebView(object):
                 
         
         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']