Mercurial > libervia-web
annotate src/pages/forums/view/page_meta.py @ 1091:092e910292c9
pages (chat): don't change session.jid anymore, as it is now set on log-in
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 01 Jun 2018 12:56:13 +0200 |
parents | 880ea673aaff |
children | cdd389ef97bc |
rev | line source |
---|---|
1058 | 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 log = getLogger('pages/forums/view') | |
9 | |
10 name = u"forum_view" | |
11 access = C.PAGES_ACCESS_PUBLIC | |
12 template = u"forum/view.html" | |
13 | |
14 | |
15 def parse_url(self, request): | |
16 self.getPathArgs(request, ['service', 'node'], 2, | |
17 service = u'jid') | |
18 | |
19 @defer.inlineCallbacks | |
20 def prepare_render(self, request): | |
21 data = self.getRData(request) | |
22 data['show_comments'] = False | |
1077
880ea673aaff
blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
1058
diff
changeset
|
23 blog_page = self.getPageByName(u'blog_view') |
1058 | 24 request.args['before'] = [''] |
25 request.args['reverse'] = ['1'] | |
26 yield blog_page.prepare_render(self, request) | |
27 request.template_data[u'login_url'] = self.getPageRedirectURL(request) | |
28 | |
29 @defer.inlineCallbacks | |
30 def on_data_post(self, request): | |
31 profile = self.getProfile(request) | |
32 if profile is None: | |
33 self.pageError(request, C.HTTP_UNAUTHORIZED) | |
34 type_ = self.getPostedData(request, u'type') | |
35 if type_ == u'comment': | |
36 service, node, body = self.getPostedData(request, (u'service', u'node', u'body')) | |
37 | |
38 if not body: | |
39 self.pageError(request, C.HTTP_BAD_REQUEST) | |
40 mb_data = {u"content": body} | |
41 try: | |
42 yield self.host.bridgeCall(u'mbSend', service, node, mb_data, profile) | |
43 except Exception as e: | |
44 if u"forbidden" in unicode(e): | |
45 self.pageError(request, 401) | |
46 else: | |
47 raise e | |
48 else: | |
49 log.warning(_(u"Unhandled data type: {}").format(type_)) |