comparison libervia/pages/forums/view/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/view/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.i18n import _
7 from sat.core.log import getLogger
8
9 log = getLogger("pages/forums/view")
10
11 name = u"forum_view"
12 access = C.PAGES_ACCESS_PUBLIC
13 template = u"forum/view.html"
14
15
16 def parse_url(self, request):
17 self.getPathArgs(request, ["service", "node"], 2, service=u"jid")
18
19
20 @defer.inlineCallbacks
21 def prepare_render(self, request):
22 data = self.getRData(request)
23 data["show_comments"] = False
24 blog_page = self.getPageByName(u"blog_view")
25 request.args["before"] = [""]
26 request.args["reverse"] = ["1"]
27 yield blog_page.prepare_render(self, request)
28 request.template_data[u"login_url"] = self.getPageRedirectURL(request)
29
30
31 @defer.inlineCallbacks
32 def on_data_post(self, request):
33 profile = self.getProfile(request)
34 if profile is None:
35 self.pageError(request, C.HTTP_UNAUTHORIZED)
36 type_ = self.getPostedData(request, u"type")
37 if type_ == u"comment":
38 service, node, body = self.getPostedData(request, (u"service", u"node", u"body"))
39
40 if not body:
41 self.pageError(request, C.HTTP_BAD_REQUEST)
42 mb_data = {u"content": body}
43 try:
44 yield self.host.bridgeCall(u"mbSend", service, node, mb_data, profile)
45 except Exception as e:
46 if u"forbidden" in unicode(e):
47 self.pageError(request, 401)
48 else:
49 raise e
50 else:
51 log.warning(_(u"Unhandled data type: {}").format(type_))