]>
Commit | Line | Data |
---|---|---|
66862195 MT |
1 | #!/usr/bin/python |
2 | ||
3 | import tornado.web | |
4 | ||
5 | from handlers_base import * | |
6 | ||
7 | class TalkIndexHandler(BaseHandler): | |
8 | @tornado.web.authenticated | |
9 | def get(self): | |
10 | call_log = self.talk.get_call_log(self.current_user, limit=6) | |
11 | favourite_contacts = self.talk.get_favourite_contacts(self.current_user) | |
12 | ||
66862195 | 13 | self.render("talk/index.html", call_log=call_log, |
5ac74b02 | 14 | favourite_contacts=favourite_contacts) |
66862195 MT |
15 | |
16 | ||
17 | class TalkPhonebookHandler(BaseHandler): | |
18 | @tornado.web.authenticated | |
19 | def get(self): | |
20 | phonebook = self.talk.get_phonebook(self.current_user) | |
21 | ||
22 | self.render("talk/phonebook.html", phonebook=phonebook) | |
23 | ||
24 | ||
25 | class TalkPhonebookAccountHandler(BaseHandler): | |
26 | @tornado.web.authenticated | |
27 | def get(self, uid): | |
28 | account = self.accounts.find(uid) | |
29 | if not account: | |
30 | raise tornado.web.HTTPError(404, "Account not found: %s" % uid) | |
31 | ||
77431b9c | 32 | self.render("talk/phonebook-contact.html", account=account) |
66862195 MT |
33 | |
34 | ||
35 | class TalkDiagnosisHandler(BaseHandler): | |
36 | @tornado.web.authenticated | |
37 | def get(self): | |
78439bec MT |
38 | # Access only allowed for admins |
39 | if not self.current_user.is_admin(): | |
40 | raise tornado.web.HTTPError(403) | |
41 | ||
66862195 MT |
42 | return self.render("talk/diagnosis.html") |
43 | ||
44 | ||
40818cf2 MT |
45 | class TalkHangupChannelHandler(BaseHandler): |
46 | def _get_channel(self, channel_id): | |
47 | account = None if self.current_user.is_admin() else self.current_user | |
48 | ||
49 | channel = self.talk.get_channel(channel_id, account=account) | |
50 | if not channel: | |
51 | raise tornado.web.HTTPError(404) | |
52 | ||
53 | return channel | |
54 | ||
55 | @tornado.web.authenticated | |
56 | def get(self, channel_id): | |
57 | channel = self._get_channel(channel_id) | |
58 | ||
59 | self.render("talk/confirm-hangup.html", channel=channel) | |
60 | ||
61 | @tornado.web.authenticated | |
62 | def post(self, channel_id): | |
63 | channel = self._get_channel(channel_id) | |
64 | ||
65 | # Hangup | |
66 | channel.hangup() | |
67 | ||
68 | self.redirect("/") | |
69 | ||
70 | ||
66862195 MT |
71 | class TalkConferencesHandler(BaseHandler): |
72 | @tornado.web.authenticated | |
73 | def get(self): | |
74 | return self.render("talk/conferences.html", | |
75 | conferences=self.talk.conferences) | |
76 | ||
77 | ||
66862195 MT |
78 | class TalkProfileHandler(BaseHandler): |
79 | @tornado.web.authenticated | |
80 | def get(self): | |
81 | return self.redirect("/phonebook/%s" % self.current_user.uid) |