Mercurial > libervia-web
annotate src/pages/tickets/page_meta.py @ 978:c8cafe316f6f
pages: removed trailing_slash option:
this option is used for relative URLs, but it seems more reasonable to build absolute URL from the server, so templates are not dependants of the way the pages hierarchy is done.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 12 Nov 2017 12:51:56 +0100 |
parents | 2e75dc986e03 |
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 twisted.words.protocols.jabber import jid | |
8 from sat.tools.common import template_xmlui | |
9 from sat.tools.common import data_objects | |
10 from sat.core.log import getLogger | |
11 log = getLogger('pages/ticket') | |
12 """ticket handling pages""" | |
13 | |
14 name = u'tickets_list' | |
15 access = C.PAGES_ACCESS_PUBLIC | |
16 template = u"ticket/overview.html" | |
17 | |
18 | |
19 def parse_url(self, request): | |
20 try: | |
21 service = self.nextPath(request) | |
22 except IndexError: | |
23 service = u'' | |
24 else: | |
25 if not service or service == u'@': | |
26 service = u'' | |
27 | |
28 if service: | |
29 try: | |
30 service = jid.JID(service) | |
31 except Exception: | |
32 log.warning(_(u"bad service entered: {}").format(service)) | |
33 self.pageError(request, C.HTTP_BAD_REQUEST) | |
34 | |
35 try: | |
36 node = self.nextPath(request) | |
37 except IndexError: | |
38 node = u'' | |
39 else: | |
40 if not node or node == u'@': | |
41 node = u'' | |
42 | |
43 data = self.getRData(request) | |
44 data['service'] = service | |
45 data['node'] = node | |
46 | |
973
2e75dc986e03
pages (tickets): URLs for list and new are set in the template for the whole subhierarchy
Goffi <goffi@goffi.org>
parents:
967
diff
changeset
|
47 template_data = request.template_data |
2e75dc986e03
pages (tickets): URLs for list and new are set in the template for the whole subhierarchy
Goffi <goffi@goffi.org>
parents:
967
diff
changeset
|
48 template_data[u'url_tickets_list'] = self.getPageByName('tickets_list').getURL(service.full(), node or u'@') |
2e75dc986e03
pages (tickets): URLs for list and new are set in the template for the whole subhierarchy
Goffi <goffi@goffi.org>
parents:
967
diff
changeset
|
49 template_data[u'url_tickets_new'] = u'/' + ('/'.join(request.prepath + ['new']).decode('utf-8')) |
967 | 50 |
51 @defer.inlineCallbacks | |
52 def prepare_render(self, request): | |
53 data = self.getRData(request) | |
54 template_data = request.template_data | |
55 service, node = data.get(u'service', u''), data.get(u'node', u'') | |
56 profile = self.getProfile(request) or C.SERVICE_PROFILE | |
57 | |
58 tickets = yield self.host.bridge.ticketsGet(service.full() if service else u'', node, C.NO_LIMIT, [], '', {}, profile) | |
59 tickets = [template_xmlui.create(self.host, x) for x in tickets[0]] | |
60 template_data[u'tickets'] = tickets | |
61 template_data[u'on_ticket_click'] = data_objects.OnClick(url="view/{item.id}") |