]> git.ipfire.org Git - ipfire.org.git/commitdiff
talk: Allow admins to see registrations of all users
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 10 Oct 2018 13:42:41 +0000 (14:42 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 10 Oct 2018 13:42:41 +0000 (14:42 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/backend/accounts.py
src/backend/talk.py
src/templates/talk/modules/registrations.html
src/templates/talk/registrations.html
src/web/__init__.py
src/web/talk.py

index 3a80b7b39b1c7c2a90ee4bb2aea742ef3396a672..7e6e4431d5672fde36a1aa744eb53aa95cf3cbb4 100644 (file)
@@ -229,7 +229,7 @@ class Account(Object):
                        for dn, attrs in res:
                                cns = attrs.get("cn")
                                if cns:
-                                       self._groups.append(cns[0])
+                                       self._groups.append(cns[0].decode())
 
                return self._groups
 
index d9e475202305cf2fcffe26d4576b098fea8df518..9b7d2f626b0fa99fe214d5ca94dd8b862e2c0b1e 100644 (file)
@@ -63,7 +63,7 @@ class SIPRegistration(object):
 
        @lazy_property
        def latency(self):
-               if self.is_reachable():
+               if self.is_reachable() and self.data.ping_time:
                        return self.data.ping_time / 1000.0
 
 
index 85e349f5aea375f6bd88adce7a302518a491ef12..0143b389c1944df2641e03ca59c6d87e73bc2549 100644 (file)
@@ -5,7 +5,7 @@
                                <td>{{ reg.user_agent }}</td>
                                <td>{{ reg.protocol }}/{{ reg.network_ip }}:{{ reg.network_port }}</td>
                                <td class="text-right">
-                                       {% if reg.is_reachable() %}
+                                       {% if reg.is_reachable() and reg.latency %}
                                                {{ "%.2f ms" % reg.latency }}
                                        {% else %}
                                                <span class="text-muted">{{ _("N/A") }}</span>
index a0b8939bf1b8ad7b2354a987216fbecdffe8ced5..98538d94797c69e497dfae336f1c9f6c27761ece 100644 (file)
@@ -6,10 +6,10 @@
     <div class="card">
         <div class="card-body">
             <h6 class="card-title">
-                {{ _("Active Registrations for %s") % current_user }}
+                {{ _("Active Registrations for %s") % account }}
             </h6>
 
-            {% module TalkRegistrations(current_user) %}
+            {% module TalkRegistrations(account) %}
         </div>
     </div>
 {% end block %}
index 2fb746512a50b86f2368445d8230d41618bf133e..3bf077bee06fd3bbf3c7e95617ba626cf2bfb5de 100644 (file)
@@ -239,7 +239,7 @@ class Application(tornado.web.Application):
                # talk.ipfire.org
                self.add_handlers(r"talk(\.dev)?\.ipfire\.org", [
                        (r"/", talk.IndexHandler),
-                       (r"/registrations", talk.RegistrationsHandler),
+                       (r"/user/(\w+)/registrations", talk.RegistrationsHandler),
                        (r"/conferences", TalkConferencesHandler),
                        (r"/diagnosis", TalkDiagnosisHandler),
                        (r"/hangup/(.*)", TalkHangupChannelHandler),
index b6a6da87a82e15f80c1635568330c554033951e8..c3158eec4a7b598538c69ac24c2c7f62ba604894 100644 (file)
@@ -13,8 +13,22 @@ class IndexHandler(base.BaseHandler):
 
 class RegistrationsHandler(base.BaseHandler):
        @tornado.web.authenticated
-       def get(self):
-               self.render("talk/registrations.html")
+       def get(self, uid):
+               # Get own account
+               if self.current_user.uid == uid:
+                       account = self.current_user
+
+               # Admins can access all other users, too
+               elif self.current_user.is_admin():
+                       account = self.backend.accounts.get_by_uid(uid)
+                       if not account:
+                               raise tornado.web.HTTPError(404, "Could not find account %s" % uid)
+
+               # Otherwise, no access is permitted
+               else:
+                       raise tornado.web.HTTPError(403)
+
+               self.render("talk/registrations.html", account=account)
 
 
 class RegistrationsModule(ui_modules.UIModule):