Mercurial > libervia-web
annotate src/pages/tickets/page_meta.py @ 1054:f2170536ba23
date update
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 26 Jan 2018 11:15:26 +0100 |
parents | d8666fdb015c |
children | 296bda6b7ed0 |
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): | |
981
97cce8c1e96a
pages(tickets): better URL handling:
Goffi <goffi@goffi.org>
parents:
978
diff
changeset
|
20 # check the service and node to use |
967 | 21 try: |
22 service = self.nextPath(request) | |
981
97cce8c1e96a
pages(tickets): better URL handling:
Goffi <goffi@goffi.org>
parents:
978
diff
changeset
|
23 node = self.nextPath(request) |
967 | 24 except IndexError: |
981
97cce8c1e96a
pages(tickets): better URL handling:
Goffi <goffi@goffi.org>
parents:
978
diff
changeset
|
25 log.warning(_(u"missing service and node")) |
97cce8c1e96a
pages(tickets): better URL handling:
Goffi <goffi@goffi.org>
parents:
978
diff
changeset
|
26 self.pageError(request, C.HTTP_BAD_REQUEST) |
97cce8c1e96a
pages(tickets): better URL handling:
Goffi <goffi@goffi.org>
parents:
978
diff
changeset
|
27 |
97cce8c1e96a
pages(tickets): better URL handling:
Goffi <goffi@goffi.org>
parents:
978
diff
changeset
|
28 if not service or service == u'@': |
967 | 29 service = u'' |
30 | |
31 if service: | |
32 try: | |
33 service = jid.JID(service) | |
34 except Exception: | |
35 log.warning(_(u"bad service entered: {}").format(service)) | |
36 self.pageError(request, C.HTTP_BAD_REQUEST) | |
37 | |
981
97cce8c1e96a
pages(tickets): better URL handling:
Goffi <goffi@goffi.org>
parents:
978
diff
changeset
|
38 if not node or node == u'@': |
967 | 39 node = u'' |
40 | |
41 data = self.getRData(request) | |
42 data['service'] = service | |
43 data['node'] = node | |
44 | |
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
|
45 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
|
46 template_data[u'url_tickets_list'] = self.getPageByName('tickets_list').getURL(service.full(), node or u'@') |
981
97cce8c1e96a
pages(tickets): better URL handling:
Goffi <goffi@goffi.org>
parents:
978
diff
changeset
|
47 template_data[u'url_tickets_new'] = self.getSubPageURL(request, 'tickets_new') |
967 | 48 |
49 @defer.inlineCallbacks | |
50 def prepare_render(self, request): | |
51 data = self.getRData(request) | |
52 template_data = request.template_data | |
981
97cce8c1e96a
pages(tickets): better URL handling:
Goffi <goffi@goffi.org>
parents:
978
diff
changeset
|
53 service, node = data[u'service'], data[u'node'] |
967 | 54 profile = self.getProfile(request) or C.SERVICE_PROFILE |
55 | |
1021
b39c527f208c
pages (tickets): check cache in prepare_render instead of parse_url
Goffi <goffi@goffi.org>
parents:
1007
diff
changeset
|
56 self.checkCache(request, C.CACHE_PUBSUB, service=service, node=node, short='tickets') |
b39c527f208c
pages (tickets): check cache in prepare_render instead of parse_url
Goffi <goffi@goffi.org>
parents:
1007
diff
changeset
|
57 |
1007
c1c74d97a691
pages(tickets): use bridgeCall instead of bridge
Goffi <goffi@goffi.org>
parents:
986
diff
changeset
|
58 tickets = yield self.host.bridgeCall('ticketsGet', service.full() if service else u'', node, C.NO_LIMIT, [], '', {}, profile) |
981
97cce8c1e96a
pages(tickets): better URL handling:
Goffi <goffi@goffi.org>
parents:
978
diff
changeset
|
59 template_data[u'tickets'] = [template_xmlui.create(self.host, x) for x in tickets[0]] |
1043
d8666fdb015c
pages (tickets, merge-requests): fixed items URLs
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
60 template_data[u'on_ticket_click'] = data_objects.OnClick(url=self.getSubPageURL(request, u'tickets_view') + u'/{item.id}') |