]> git.ipfire.org Git - people/shoehn/ipfire.org.git/blobdiff - webapp/ui_modules.py
talk: Update for Kamailio
[people/shoehn/ipfire.org.git] / webapp / ui_modules.py
index f61cfca89ca554edcbf2dc0da145b903969c18c4..4b4e9c9c86504aff4b91ab11ac5506c78f2eae77 100644 (file)
@@ -48,6 +48,10 @@ class UIModule(tornado.web.UIModule):
        def planet(self):
                return self.handler.planet
 
+       @property
+       def talk(self):
+               return self.handler.talk
+
        @property
        def wishlist(self):
                return self.handler.wishlist
@@ -323,13 +327,45 @@ class ProgressBarModule(UIModule):
 
 
 class TalkCallLogModule(UIModule):
-       def render(self, calls):
-               return self.render_string("talk/modules/call-log.html", calls=calls)
+       def render(self, account=None, viewer=None):
+               if (account is None or not self.current_user == account) \
+                               and not self.current_user.is_admin():
+                       raise RuntimeException("Insufficient permissions")
+
+               if viewer is None:
+                       viewer = self.current_user
+
+               calls = self.talk.get_call_log(account)
+
+               return self.render_string("talk/modules/call-log.html",
+                       calls=calls, viewer=viewer)
+
+
+class TalkLinesModule(UIModule):
+       def render(self, account=None, show_account=False):
+               if (account is None or not self.current_user == account) \
+                               and not self.current_user.is_admin():
+                       raise RuntimeException("Insufficient permissions")
+
+               lines = self.talk.get_lines(account)
+
+               return self.render_string("talk/modules/lines.html",
+                       show_account=show_account, lines=lines)
 
 
 class TalkOngoingCallsModule(UIModule):
-       def render(self, calls):
-               return self.render_string("talk/modules/ongoing-calls.html", calls=calls)
+       def render(self, account=None):
+               if (account is None or not self.current_user == account) \
+                               and not self.current_user.is_admin():
+                       raise RuntimeException("Insufficient permissions")
+
+               calls = self.talk.get_ongoing_calls(account)
+
+               if calls:
+                       return self.render_string("talk/modules/ongoing-calls.html",
+                               calls=calls)
+
+               return ""
 
 
 class TrackerPeerListModule(UIModule):