]> git.ipfire.org Git - ipfire.org.git/commitdiff
people: Rename registrations page
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 17 Oct 2018 12:58:55 +0000 (13:58 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 17 Oct 2018 15:12:45 +0000 (16:12 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/templates/people/modules/sip-status.html
src/templates/people/sip.html [moved from src/templates/people/registrations.html with 100% similarity]
src/web/__init__.py
src/web/people.py

index 92b14c4dda32e3f56b97d4dbcacf2944b7ef07cd..a341c3d4b2a14e1037dfb96e3395e1cb9f414220 100644 (file)
@@ -157,8 +157,8 @@ templates_people_DATA = \
        src/templates/people/calls.html \
        src/templates/people/index.html \
        src/templates/people/passwd.html \
-       src/templates/people/registrations.html \
        src/templates/people/search.html \
+       src/templates/people/sip.html \
        src/templates/people/user.html \
        src/templates/people/user-edit.html \
        src/templates/people/users.html
index c1626fbeac21a81e1e7d1b17906a70a152e6f5de..ab4b93122b93c153e3f5015463c7f43c92c2c081 100644 (file)
@@ -1,9 +1,9 @@
 {% if account.sip_channels %}
-    <a class="text-warning" href="/users/{{ account.uid }}/registrations">
+    <a class="text-warning" href="/users/{{ account.uid }}/sip">
         {{ _("On The Phone") }} ({{ len(account.sip_registrations) }})
     </a>
 {% elif account.sip_registrations %}
-    <a class="text-success" href="/users/{{ account.uid }}/registrations">
+    <a class="text-success" href="/users/{{ account.uid }}/sip">
         {{ _("Online") }} ({{ len(account.sip_registrations) }})
     </a>
 {% else %}
index b80ac84c0129d9ff149d71dbdf0f4e9757bf9e60..70b44985d53a9dac42f3f5a9c020f459ffd8cf40 100644 (file)
@@ -260,7 +260,7 @@ class Application(tornado.web.Application):
                        (r"/users/(\w+)/calls(?:/(\d{4}-\d{2}-\d{2}))?", people.CallsHandler),
                        (r"/users/(\w+)/edit", people.UserEditHandler),
                        (r"/users/(\w+)/passwd", people.UserPasswdHandler),
-                       (r"/users/(\w+)/registrations", people.RegistrationsHandler),
+                       (r"/users/(\w+)/sip", people.SIPHandler),
                ]  + authentication_handlers)
 
                # ipfire.org
index 595a9483b6701ca85e3acce25ad3bef27518df47..ad15abf4739dd0fb75fc3a7182880b79b1924741 100644 (file)
@@ -83,26 +83,6 @@ class CallHandler(base.BaseHandler):
                self.render("people/call.html", call=call)
 
 
-class RegistrationsHandler(base.BaseHandler):
-       @tornado.web.authenticated
-       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("people/registrations.html", account=account)
-
-
 class SearchHandler(base.BaseHandler):
        @tornado.web.authenticated
        def get(self):
@@ -119,6 +99,20 @@ class SearchHandler(base.BaseHandler):
                self.render("people/search.html", q=q, accounts=accounts)
 
 
+class SIPHandler(base.BaseHandler):
+       @tornado.web.authenticated
+       def get(self, uid):
+               account = self.backend.accounts.get_by_uid(uid)
+               if not account:
+                       raise tornado.web.HTTPError(404, "Could not find account %s" % uid)
+
+               # Check for permissions
+               if not account.can_be_managed_by(self.current_user):
+                       raise tornado.web.HTTPError(403, "%s cannot manage %s" % (self.current_user, account))
+
+               self.render("people/sip.html", account=account)
+
+
 class UsersHandler(base.BaseHandler):
        @tornado.web.authenticated
        def get(self):