Mercurial > libervia-web
annotate src/pages/tickets/view/page_meta.py @ 980:bcacf970f970
core (pages redirection): inverted redirection + getSubPageURL:
- page redirection now also work in other redirection meaning that if "/redirecting_url" => "/page_name/arg_1/arg_2" is used,
a getURL(page_name, arg_1, arg_2) will return the redirecting_url.
query_args are not handled yet by getURL.
- page redirection dict now use path_args and query_args insteand of args and kwargs, which show the relation with URL.
- new getSubPageURL return absolute URL to a subpage, which is more solid than relative URL and allows to use it in sub-hierarchy.
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 14 Nov 2017 08:35:17 +0100 |
parents | 75166ac3e0cc |
children | 97cce8c1e96a |
rev | line source |
---|---|
967 | 1 #!/usr/bin/env python2.7 |
2 # -*- coding: utf-8 -*- | |
3 | |
4 from libervia.server.constants import Const as C | |
5 from sat.core.i18n import _ | |
6 from twisted.internet import defer | |
7 from sat.tools.common import template_xmlui | |
8 from sat.tools.common import uri | |
9 from sat.tools.common import data_objects | |
10 from sat.core.log import getLogger | |
11 log = getLogger('pages/tickets/view') | |
12 """ticket handling pages""" | |
13 | |
14 access = C.PAGES_ACCESS_PUBLIC | |
15 template = u"ticket/item.html" | |
16 | |
17 | |
18 def parse_url(self, request): | |
19 try: | |
20 item_id = self.nextPath(request) | |
21 except IndexError: | |
22 log.warning(_(u"no ticket id specified")) | |
23 self.pageError(request, C.HTTP_BAD_REQUEST) | |
24 | |
25 data = self.getRData(request) | |
26 data[u'ticket_id'] = item_id | |
27 | |
28 @defer.inlineCallbacks | |
29 def prepare_render(self, request): | |
30 data = self.getRData(request) | |
31 template_data = request.template_data | |
32 service, node, ticket_id = data.get(u'service', u''), data.get(u'node', u''), data[u'ticket_id'] | |
33 profile = self.getProfile(request) | |
34 | |
35 if profile is None: | |
36 profile = C.SERVICE_PROFILE | |
37 else: | |
38 template_data['profile'] = profile | |
39 | |
40 tickets = yield self.host.bridge.ticketsGet(service.full() if service else u'', node, C.NO_LIMIT, [ticket_id], '', {}, profile) | |
975
75166ac3e0cc
pages (tickets/view): ignore publisher when creating XMLUI
Goffi <goffi@goffi.org>
parents:
967
diff
changeset
|
41 ticket = [template_xmlui.create(self.host, x, ignore=['publisher']) for x in tickets[0]][0] |
967 | 42 template_data[u'item'] = ticket |
43 comments_uri = ticket.widgets['comments_uri'].value | |
44 if comments_uri: | |
45 uri_data = uri.parseXMPPUri(comments_uri) | |
46 template_data['comments_node'] = comments_node = uri_data['node'] | |
47 template_data['comments_service'] = comments_service = uri_data['path'] | |
48 comments = yield self.host.bridge.mbGet(comments_service, | |
49 comments_node, | |
50 C.NO_LIMIT, | |
51 [], | |
52 {}, | |
53 profile) | |
54 | |
55 template_data[u'comments'] = data_objects.BlogItems(comments) | |
56 template_data[u'login_url'] = self.getPageRedirectURL(request) | |
57 | |
58 @defer.inlineCallbacks | |
59 def on_data_post(self, request): | |
60 type_ = self.getPostedData(request, u'type') | |
61 if type_ == u'comment': | |
62 blog_page = self.getPageByName(u'blog') | |
63 yield blog_page.on_data_post(self, request) | |
64 else: | |
65 log.warning(_(u"Unhandled data type: {}").format(type_)) |