From: Michael Tremer Date: Mon, 15 Oct 2018 11:28:42 +0000 (+0100) Subject: Move talk.ipfire.org -> people.ipfire.org X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=786e9ca8f6df05304e474ac08ec96f9047df9287;p=ipfire.org.git Move talk.ipfire.org -> people.ipfire.org Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index 92326b1e..a0e3b52d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -84,10 +84,8 @@ web_PYTHON = \ src/web/handlers_iuse.py \ src/web/handlers_mirrors.py \ src/web/handlers_nopaste.py \ - src/web/handlers_talk.py \ src/web/location.py \ src/web/people.py \ - src/web/talk.py \ src/web/ui_modules.py webdir = $(backenddir)/web @@ -148,6 +146,24 @@ templates_modules_DATA = \ templates_modulesdir = $(templatesdir)/modules +templates_people_DATA = \ + src/templates/people/base.html \ + src/templates/people/index.html \ + src/templates/people/registrations.html \ + src/templates/people/search.html \ + src/templates/people/user.html \ + src/templates/people/users.html + +templates_peopledir = $(templatesdir)/people + +templates_people_modules_DATA = \ + src/templates/people/modules/accounts-list.html \ + src/templates/people/modules/cdr.html \ + src/templates/people/modules/channels.html \ + src/templates/people/modules/registrations.html + +templates_people_modulesdir = $(templates_peopledir)/modules + templates_static_DATA = \ src/templates/static/features.html \ src/templates/static/get-involved.html \ @@ -158,24 +174,6 @@ templates_static_DATA = \ templates_staticdir = $(templatesdir)/static -templates_talk_DATA = \ - src/templates/talk/base.html \ - src/templates/talk/index.html \ - src/templates/talk/registrations.html \ - src/templates/talk/search.html \ - src/templates/talk/user.html \ - src/templates/talk/users.html - -templates_talkdir = $(templatesdir)/talk - -templates_talk_modules_DATA = \ - src/templates/talk/modules/accounts-list.html \ - src/templates/talk/modules/cdr.html \ - src/templates/talk/modules/channels.html \ - src/templates/talk/modules/registrations.html - -templates_talk_modulesdir = $(templates_talkdir)/modules - # ------------------------------------------------------------------------------ SCSS_FILES = \ diff --git a/src/templates/talk/base.html b/src/templates/people/base.html similarity index 96% rename from src/templates/talk/base.html rename to src/templates/people/base.html index 1afa1a33..d92db680 100644 --- a/src/templates/talk/base.html +++ b/src/templates/people/base.html @@ -1,6 +1,6 @@ {% extends "../base.html" %} -{% block subtitle %}{{ _("Talk") }}{% end block %} +{% block subtitle %}{{ _("People") }}{% end block %} {% block menu %} {% if current_user %} diff --git a/src/templates/talk/index.html b/src/templates/people/index.html similarity index 100% rename from src/templates/talk/index.html rename to src/templates/people/index.html diff --git a/src/templates/talk/modules/accounts-list.html b/src/templates/people/modules/accounts-list.html similarity index 100% rename from src/templates/talk/modules/accounts-list.html rename to src/templates/people/modules/accounts-list.html diff --git a/src/templates/talk/modules/cdr.html b/src/templates/people/modules/cdr.html similarity index 100% rename from src/templates/talk/modules/cdr.html rename to src/templates/people/modules/cdr.html diff --git a/src/templates/talk/modules/channels.html b/src/templates/people/modules/channels.html similarity index 100% rename from src/templates/talk/modules/channels.html rename to src/templates/people/modules/channels.html diff --git a/src/templates/talk/modules/registrations.html b/src/templates/people/modules/registrations.html similarity index 100% rename from src/templates/talk/modules/registrations.html rename to src/templates/people/modules/registrations.html diff --git a/src/templates/talk/registrations.html b/src/templates/people/registrations.html similarity index 100% rename from src/templates/talk/registrations.html rename to src/templates/people/registrations.html diff --git a/src/templates/talk/search.html b/src/templates/people/search.html similarity index 100% rename from src/templates/talk/search.html rename to src/templates/people/search.html diff --git a/src/templates/talk/user.html b/src/templates/people/user.html similarity index 100% rename from src/templates/talk/user.html rename to src/templates/people/user.html diff --git a/src/templates/talk/users.html b/src/templates/people/users.html similarity index 100% rename from src/templates/talk/users.html rename to src/templates/people/users.html diff --git a/src/web/__init__.py b/src/web/__init__.py index 91fb4eb8..88fcd270 100644 --- a/src/web/__init__.py +++ b/src/web/__init__.py @@ -16,7 +16,6 @@ from . import blog from . import download from . import location from . import people -from . import talk from . import ui_modules class Application(tornado.web.Application): @@ -56,10 +55,10 @@ class Application(tornado.web.Application): "Map" : ui_modules.MapModule, # Talk - "TalkAccountsList" : talk.AccountsListModule, - "TalkCDR" : talk.CDRModule, - "TalkChannels" : talk.ChannelsModule, - "TalkRegistrations" : talk.RegistrationsModule, + "TalkAccountsList" : people.AccountsListModule, + "TalkCDR" : people.CDRModule, + "TalkChannels" : people.ChannelsModule, + "TalkRegistrations" : people.RegistrationsModule, # Old modules "LanguageName" : ui_modules.LanguageNameModule, @@ -240,23 +239,18 @@ class Application(tornado.web.Application): # talk.ipfire.org self.add_handlers(r"talk(\.dev)?\.ipfire\.org", [ - (r"/", talk.IndexHandler), - (r"/search", talk.SearchHandler), - (r"/users", talk.UsersHandler), - (r"/users/(\w+)", talk.UserHandler), - (r"/users/(\w+)/registrations", talk.RegistrationsHandler), - (r"/conferences", TalkConferencesHandler), - (r"/diagnosis", TalkDiagnosisHandler), - (r"/hangup/(.*)", TalkHangupChannelHandler), - (r"/phonebook/(\w+)", TalkPhonebookAccountHandler), - (r"/phonebook", TalkPhonebookHandler), - (r"/profile", TalkProfileHandler), - ] + authentication_handlers) + (r"/", tornado.web.RedirectHandler, { "url" : "https://people.ipfire.org/" }), + ]) # people.ipfire.org self.add_handlers(r"people(\.dev)?\.ipfire\.org", [ + (r"/", people.IndexHandler), + (r"/search", people.SearchHandler), + (r"/users", people.UsersHandler), + (r"/users/(\w+)", people.UserHandler), (r"/users/(\w+)\.jpg", people.AvatarHandler), - ]) + (r"/users/(\w+)/registrations", people.RegistrationsHandler), + ] + authentication_handlers) # ipfire.org self.add_handlers(r"ipfire\.org", [ diff --git a/src/web/handlers_talk.py b/src/web/handlers_talk.py deleted file mode 100644 index a4230f51..00000000 --- a/src/web/handlers_talk.py +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/python - -import tornado.web - -from .handlers_base import * - -class TalkIndexHandler(BaseHandler): - @tornado.web.authenticated - def get(self): - self.render("talk/index.html") - - -class TalkPhonebookHandler(BaseHandler): - @tornado.web.authenticated - def get(self): - phonebook = self.talk.get_phonebook(self.current_user) - - self.render("talk/phonebook.html", phonebook=phonebook) - - -class TalkPhonebookAccountHandler(BaseHandler): - @tornado.web.authenticated - def get(self, uid): - account = self.accounts.find(uid) - if not account: - raise tornado.web.HTTPError(404, "Account not found: %s" % uid) - - self.render("talk/phonebook-contact.html", account=account) - - -class TalkDiagnosisHandler(BaseHandler): - @tornado.web.authenticated - def get(self): - # Access only allowed for admins - if not self.current_user.is_admin(): - raise tornado.web.HTTPError(403) - - return self.render("talk/diagnosis.html") - - -class TalkHangupChannelHandler(BaseHandler): - def _get_channel(self, channel_id): - account = None if self.current_user.is_admin() else self.current_user - - channel = self.talk.get_channel(channel_id, account=account) - if not channel: - raise tornado.web.HTTPError(404) - - return channel - - @tornado.web.authenticated - def get(self, channel_id): - channel = self._get_channel(channel_id) - - self.render("talk/confirm-hangup.html", channel=channel) - - @tornado.web.authenticated - def post(self, channel_id): - channel = self._get_channel(channel_id) - - # Hangup - channel.hangup() - - self.redirect("/") - - -class TalkConferencesHandler(BaseHandler): - @tornado.web.authenticated - def get(self): - return self.render("talk/conferences.html", - conferences=self.talk.conferences) - - -class TalkProfileHandler(BaseHandler): - @tornado.web.authenticated - def get(self): - return self.redirect("/phonebook/%s" % self.current_user.uid) diff --git a/src/web/people.py b/src/web/people.py index de2ac8bd..face462c 100644 --- a/src/web/people.py +++ b/src/web/people.py @@ -4,6 +4,13 @@ import logging import tornado.web from . import handlers_base as base +from . import ui_modules + +class IndexHandler(base.BaseHandler): + @tornado.web.authenticated + def get(self): + self.render("people/index.html") + class AvatarHandler(base.BaseHandler): def get(self, uid): @@ -40,3 +47,82 @@ class AvatarHandler(base.BaseHandler): # Deliver payload self.finish(avatar) + + +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): + q = self.get_argument("q") + + # Perform the search + accounts = self.backend.talk.search(q) + + # Redirect when only one result was found + if len(accounts) == 1: + self.redirect("/users/%s" % accounts[0].uid) + return + + self.render("people/search.html", q=q, accounts=accounts) + + +class UsersHandler(base.BaseHandler): + @tornado.web.authenticated + def get(self): + self.render("people/users.html") + + +class UserHandler(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) + + self.render("people/user.html", account=account) + + +class AccountsListModule(ui_modules.UIModule): + def render(self, accounts=None): + if accounts is None: + accounts = self.backend.talk.accounts + + return self.render_string("people/modules/accounts-list.html", accounts=accounts) + + +class CDRModule(ui_modules.UIModule): + def render(self, account, limit=None): + cdr = account.get_cdr(limit=limit) + + return self.render_string("people/modules/cdr.html", account=account, cdr=cdr) + + +class ChannelsModule(ui_modules.UIModule): + def render(self, account): + channels = self.backend.talk.freeswitch.get_sip_channels(account) + + return self.render_string("people/modules/channels.html", account=account, channels=channels) + + +class RegistrationsModule(ui_modules.UIModule): + def render(self, account): + return self.render_string("people/modules/registrations.html", account=account) diff --git a/src/web/talk.py b/src/web/talk.py deleted file mode 100644 index 8ce8e6c4..00000000 --- a/src/web/talk.py +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/python - -import tornado.web - -from . import handlers_base as base -from . import ui_modules - -class IndexHandler(base.BaseHandler): - @tornado.web.authenticated - def get(self): - self.render("talk/index.html") - - -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("talk/registrations.html", account=account) - - -class SearchHandler(base.BaseHandler): - @tornado.web.authenticated - def get(self): - q = self.get_argument("q") - - # Perform the search - accounts = self.backend.talk.search(q) - - # Redirect when only one result was found - if len(accounts) == 1: - self.redirect("/users/%s" % accounts[0].uid) - return - - self.render("talk/search.html", q=q, accounts=accounts) - - -class UsersHandler(base.BaseHandler): - @tornado.web.authenticated - def get(self): - self.render("talk/users.html") - - -class UserHandler(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) - - self.render("talk/user.html", account=account) - - -class AccountsListModule(ui_modules.UIModule): - def render(self, accounts=None): - if accounts is None: - accounts = self.backend.talk.accounts - - return self.render_string("talk/modules/accounts-list.html", accounts=accounts) - - -class CDRModule(ui_modules.UIModule): - def render(self, account, limit=None): - cdr = account.get_cdr(limit=limit) - - return self.render_string("talk/modules/cdr.html", account=account, cdr=cdr) - - -class ChannelsModule(ui_modules.UIModule): - def render(self, account): - channels = self.backend.talk.freeswitch.get_sip_channels(account) - - return self.render_string("talk/modules/channels.html", account=account, channels=channels) - - -class RegistrationsModule(ui_modules.UIModule): - def render(self, account): - return self.render_string("talk/modules/registrations.html", account=account)