]>
git.ipfire.org Git - ipfire.org.git/blob - webapp/handlers_talk.py
e422a0cc95a33a8b4768941708d8ec3b02777f8d
5 from handlers_base
import *
7 class TalkIndexHandler(BaseHandler
):
8 @tornado.web
.authenticated
10 call_log
= self
.talk
.get_call_log(self
.current_user
, limit
=6)
11 favourite_contacts
= self
.talk
.get_favourite_contacts(self
.current_user
)
13 if self
.current_user
.is_admin():
14 ongoing_calls
= self
.talk
.get_ongoing_calls()
16 ongoing_calls
= self
.talk
.get_ongoing_calls(self
.current_user
)
18 self
.render("talk/index.html", call_log
=call_log
,
19 favourite_contacts
=favourite_contacts
, ongoing_calls
=ongoing_calls
)
22 class TalkPhonebookHandler(BaseHandler
):
23 @tornado.web
.authenticated
25 phonebook
= self
.talk
.get_phonebook(self
.current_user
)
27 self
.render("talk/phonebook.html", phonebook
=phonebook
)
30 class TalkPhonebookAccountHandler(BaseHandler
):
31 @tornado.web
.authenticated
33 account
= self
.accounts
.find(uid
)
35 raise tornado
.web
.HTTPError(404, "Account not found: %s" % uid
)
37 # Get the call log, currently registered lines and ongoing calls
38 if self
.current_user
== account
or self
.current_user
.is_admin():
39 call_log
= self
.talk
.get_call_log(account
)
40 lines
= self
.talk
.get_lines(account
)
41 ongoing_calls
= self
.talk
.get_ongoing_calls(account
)
47 self
.render("talk/phonebook-contact.html", account
=account
,
48 ongoing_calls
=ongoing_calls
, call_log
=call_log
, lines
=lines
)
51 class TalkTrunksHandler(BaseHandler
):
52 @tornado.web
.authenticated
54 if not self
.current_user
.is_admin():
55 raise tornado
.web
.HTTPError(403)
57 trunks
= self
.talk
.get_trunks()
59 self
.render("talk/trunks.html", trunks
=trunks
)
62 class TalkDiagnosisHandler(BaseHandler
):
63 @tornado.web
.authenticated
65 return self
.render("talk/diagnosis.html")
68 class TalkConferencesHandler(BaseHandler
):
69 @tornado.web
.authenticated
71 return self
.render("talk/conferences.html",
72 conferences
=self
.talk
.conferences
)
75 class TalkConferencesInviteHandler(BaseHandler
):
76 @tornado.web
.authenticated
77 def get(self
, conference_id
, invitee_id
):
78 # Check for the conference room
79 conference
= self
.talk
.get_conference(conference_id
)
81 raise tornado
.web
.HTTPError(400)
83 # Ccheck for the invitee
84 invitee
= self
.accounts
.get_by_sip_id(invitee_id
)
86 raise tornado
.web
.HTTPError(400)
89 self
.talk
.initiate_call(invitee
.sip_id
, conference_id
)
91 self
.render("talk/conference-invite.html", invitee
=invitee
,
92 conference
=conference
)
95 class TalkInitiateCallHandler(BaseHandler
):
96 @tornado.web
.authenticated
97 def get(self
, called_id
, caller
=None):
98 if not self
.current_user
.sip_id
:
99 raise tornado
.web
.HTTPError(400)
101 called
= self
.accounts
.get_by_sip_id(called_id
)
103 self
.talk
.initiate_call(self
.current_user
.sip_id
, called_id
)
105 next
= self
.get_argument("next", None)
107 next
= self
.request
.headers
.get("Referer")
109 self
.render("talk/initiate-call.html", caller
=self
.current_user
,
110 called
=called
, called_id
=called_id
, next
=next
)
113 class TalkProfileHandler(BaseHandler
):
114 @tornado.web
.authenticated
116 return self
.redirect("/phonebook/%s" % self
.current_user
.uid
)