From: Michael Tremer Date: Wed, 17 Oct 2018 12:58:55 +0000 (+0100) Subject: people: Rename registrations page X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e0daee8f52d8462d25c8ee0d2bd80a17fae636c6;p=ipfire.org.git people: Rename registrations page Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index 92b14c4d..a341c3d4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 diff --git a/src/templates/people/modules/sip-status.html b/src/templates/people/modules/sip-status.html index c1626fbe..ab4b9312 100644 --- a/src/templates/people/modules/sip-status.html +++ b/src/templates/people/modules/sip-status.html @@ -1,9 +1,9 @@ {% if account.sip_channels %} - + {{ _("On The Phone") }} ({{ len(account.sip_registrations) }}) {% elif account.sip_registrations %} - + {{ _("Online") }} ({{ len(account.sip_registrations) }}) {% else %} diff --git a/src/templates/people/registrations.html b/src/templates/people/sip.html similarity index 100% rename from src/templates/people/registrations.html rename to src/templates/people/sip.html diff --git a/src/web/__init__.py b/src/web/__init__.py index b80ac84c..70b44985 100644 --- a/src/web/__init__.py +++ b/src/web/__init__.py @@ -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 diff --git a/src/web/people.py b/src/web/people.py index 595a9483..ad15abf4 100644 --- a/src/web/people.py +++ b/src/web/people.py @@ -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):