Mercurial > libervia-web
comparison libervia/pages/forums/list/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/forums/list/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 libervia.server.constants import Const as C | |
5 from twisted.internet import defer | |
6 from sat.core.log import getLogger | |
7 from sat.core.i18n import _ | |
8 from sat.tools.common import uri as xmpp_uri | |
9 | |
10 log = getLogger("pages/forum") | |
11 import json | |
12 | |
13 """forum handling pages""" | |
14 | |
15 name = u"forums" | |
16 access = C.PAGES_ACCESS_PUBLIC | |
17 template = u"forum/overview.html" | |
18 | |
19 | |
20 def parse_url(self, request): | |
21 self.getPathArgs( | |
22 request, | |
23 ["service", "node", "forum_key"], | |
24 service=u"@jid", | |
25 node=u"@", | |
26 forum_key=u"", | |
27 ) | |
28 | |
29 | |
30 def getLinks(self, forums): | |
31 for forum in forums: | |
32 try: | |
33 uri = forum["uri"] | |
34 except KeyError: | |
35 pass | |
36 else: | |
37 uri = xmpp_uri.parseXMPPUri(uri) | |
38 service = uri[u"path"] | |
39 node = uri[u"node"] | |
40 forum["http_url"] = self.getPageByName(u"forum_topics").getURL(service, node) | |
41 if u"sub-forums" in forum: | |
42 getLinks(self, forum[u"sub-forums"]) | |
43 | |
44 | |
45 @defer.inlineCallbacks | |
46 def prepare_render(self, request): | |
47 data = self.getRData(request) | |
48 template_data = request.template_data | |
49 service, node, key = data[u"service"], data[u"node"], data[u"forum_key"] | |
50 profile = self.getProfile(request) or C.SERVICE_PROFILE | |
51 | |
52 try: | |
53 forums_raw = yield self.host.bridgeCall( | |
54 "forumsGet", service.full() if service else u"", node, key, profile | |
55 ) | |
56 except Exception as e: | |
57 log.warning(_(u"Can't retrieve forums: {msg}").format(msg=e)) | |
58 forums = [] | |
59 else: | |
60 forums = json.loads(forums_raw) | |
61 getLinks(self, forums) | |
62 | |
63 template_data[u"forums"] = forums |