]> git.ipfire.org Git - ipfire.org.git/blob - src/web/talk.py
talk: Add users page
[ipfire.org.git] / src / web / talk.py
1 #!/usr/bin/python
2
3 import tornado.web
4
5 from . import handlers_base as base
6 from . import ui_modules
7
8 class IndexHandler(base.BaseHandler):
9 @tornado.web.authenticated
10 def get(self):
11 self.render("talk/index.html")
12
13
14 class RegistrationsHandler(base.BaseHandler):
15 @tornado.web.authenticated
16 def get(self, uid):
17 # Get own account
18 if self.current_user.uid == uid:
19 account = self.current_user
20
21 # Admins can access all other users, too
22 elif self.current_user.is_admin():
23 account = self.backend.accounts.get_by_uid(uid)
24 if not account:
25 raise tornado.web.HTTPError(404, "Could not find account %s" % uid)
26
27 # Otherwise, no access is permitted
28 else:
29 raise tornado.web.HTTPError(403)
30
31 self.render("talk/registrations.html", account=account)
32
33
34 class UsersHandler(base.BaseHandler):
35 @tornado.web.authenticated
36 def get(self):
37 self.render("talk/users.html")
38
39
40 class UserHandler(base.BaseHandler):
41 @tornado.web.authenticated
42 def get(self, uid):
43 account = self.backend.accounts.get_by_uid(uid)
44 if not account:
45 raise tornado.web.HTTPError(404, "Could not find account %s" % uid)
46
47 self.render("talk/user.html", account=account)
48
49
50 class AccountsListModule(ui_modules.UIModule):
51 def render(self, accounts=None):
52 if accounts is None:
53 accounts = self.backend.talk.accounts
54
55 return self.render_string("talk/modules/accounts-list.html", accounts=accounts)
56
57
58 class ChannelsModule(ui_modules.UIModule):
59 def render(self, account):
60 channels = self.backend.talk.freeswitch.get_sip_channels(account)
61
62 return self.render_string("talk/modules/channels.html", account=account, channels=channels)
63
64
65 class RegistrationsModule(ui_modules.UIModule):
66 def render(self, account):
67 return self.render_string("talk/modules/registrations.html", account=account)