comparison libervia/pages/chat/select/page_meta.py @ 1124:28e3eb3bb217

files reorganisation and installation rework: - files have been reorganised to follow other SàT projects and usual Python organisation (no more "/src" directory) - VERSION file is now used, as for other SàT projects - replace the overcomplicated setup.py be a more sane one. Pyjamas part is not compiled anymore by setup.py, it must be done separatly - removed check for data_dir if it's empty - installation tested working in virtual env - libervia launching script is now in bin/libervia
author Goffi <goffi@goffi.org>
date Sat, 25 Aug 2018 17:59:48 +0200
parents src/pages/chat/select/page_meta.py@cdd389ef97bc
children 29eb15062416
comparison
equal deleted inserted replaced
1123:63a4b8fe9782 1124:28e3eb3bb217
1 #!/usr/bin/env python2.7
2 # -*- coding: utf-8 -*-
3
4 from sat.core.i18n import _
5 from libervia.server.constants import Const as C
6 from twisted.internet import defer
7 from twisted.words.protocols.jabber import jid
8 from sat.tools.common import data_objects
9 from sat.core.log import getLogger
10
11 log = getLogger("pages/chat_select")
12
13 name = u"chat_select"
14 access = C.PAGES_ACCESS_PROFILE
15 template = u"chat/select.html"
16
17
18 @defer.inlineCallbacks
19 def prepare_render(self, request):
20 profile = self.getProfile(request)
21 template_data = request.template_data
22 rooms = template_data["rooms"] = []
23 bookmarks = yield self.host.bridgeCall("bookmarksList", "muc", "all", profile)
24 for bm_values in bookmarks.values():
25 for room_jid, room_data in bm_values.iteritems():
26 url = self.getPageByName(u"chat").getURL(room_jid)
27 rooms.append(data_objects.Room(room_jid, name=room_data.get("name"), url=url))
28 rooms.sort(key=lambda r: r.name)
29
30
31 @defer.inlineCallbacks
32 def on_data_post(self, request):
33 jid_ = self.getPostedData(request, u"jid")
34 if u"@" not in jid_:
35 profile = self.getProfile(request)
36 service = yield self.host.bridgeCall("mucGetService", "", profile)
37 if service:
38 muc_jid = jid.JID(service)
39 muc_jid.user = jid_
40 jid_ = muc_jid.full()
41 else:
42 log.warning(_(u"Invalid jid received: {jid}".format(jid=jid_)))
43 defer.returnValue(C.POST_NO_CONFIRM)
44 url = self.getPageByName(u"chat").getURL(jid_)
45 self.HTTPRedirect(request, url)