Mercurial > libervia-web
comparison libervia/pages/tickets/page_meta.py @ 1216:b2d067339de3
python 3 port:
/!\ Python 3.6+ is now needed to use libervia
/!\ instability may occur and features may not be working anymore, this will improve with time
/!\ TxJSONRPC dependency has been removed
The same procedure as in backend has been applied (check backend commit ab2696e34d29 logs
for details). Removed now deprecated code (Pyjamas compiled browser part, legacy blog,
JSON RPC related code).
Adapted code to work without `html` and `themes` dirs.
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 13 Aug 2019 19:12:31 +0200 |
parents | 29eb15062416 |
children | f511f8fbbf8a |
comparison
equal
deleted
inserted
replaced
1215:f14ab8a25e8b | 1216:b2d067339de3 |
---|---|
1 #!/usr/bin/env python2.7 | 1 #!/usr/bin/env python3 |
2 # -*- coding: utf-8 -*- | 2 # -*- coding: utf-8 -*- |
3 | 3 |
4 from libervia.server.constants import Const as C | 4 from libervia.server.constants import Const as C |
5 from twisted.internet import defer | 5 from twisted.internet import defer |
6 from sat.tools.common import template_xmlui | 6 from sat.tools.common import template_xmlui |
8 from sat.core.log import getLogger | 8 from sat.core.log import getLogger |
9 | 9 |
10 log = getLogger(__name__) | 10 log = getLogger(__name__) |
11 """ticket handling pages""" | 11 """ticket handling pages""" |
12 | 12 |
13 name = u"tickets" | 13 name = "tickets" |
14 access = C.PAGES_ACCESS_PUBLIC | 14 access = C.PAGES_ACCESS_PUBLIC |
15 template = u"ticket/overview.html" | 15 template = "ticket/overview.html" |
16 | 16 |
17 | 17 |
18 def parse_url(self, request): | 18 def parse_url(self, request): |
19 self.getPathArgs(request, ["service", "node"], service="jid") | 19 self.getPathArgs(request, ["service", "node"], service="jid") |
20 data = self.getRData(request) | 20 data = self.getRData(request) |
21 service, node = data[u"service"], data[u"node"] | 21 service, node = data["service"], data["node"] |
22 if node is None: | 22 if node is None: |
23 self.pageRedirect(u"tickets_disco", request) | 23 self.pageRedirect("tickets_disco", request) |
24 if node == u"@": | 24 if node == "@": |
25 node = data[u"node"] = u"" | 25 node = data["node"] = "" |
26 template_data = request.template_data | 26 template_data = request.template_data |
27 template_data[u"url_tickets_list"] = self.getURL(service.full(), node or u"@") | 27 template_data["url_tickets_list"] = self.getURL(service.full(), node or "@") |
28 template_data[u"url_tickets_new"] = self.getSubPageURL(request, "tickets_new") | 28 template_data["url_tickets_new"] = self.getSubPageURL(request, "tickets_new") |
29 | 29 |
30 | 30 |
31 @defer.inlineCallbacks | 31 @defer.inlineCallbacks |
32 def prepare_render(self, request): | 32 def prepare_render(self, request): |
33 data = self.getRData(request) | 33 data = self.getRData(request) |
34 template_data = request.template_data | 34 template_data = request.template_data |
35 service, node = data[u"service"], data[u"node"] | 35 service, node = data["service"], data["node"] |
36 profile = self.getProfile(request) or C.SERVICE_PROFILE | 36 profile = self.getProfile(request) or C.SERVICE_PROFILE |
37 | 37 |
38 self.checkCache(request, C.CACHE_PUBSUB, service=service, node=node, short="tickets") | 38 self.checkCache(request, C.CACHE_PUBSUB, service=service, node=node, short="tickets") |
39 | 39 |
40 extra = self.getPubsubExtra(request) | 40 extra = self.getPubsubExtra(request) |
41 extra[u"labels_as_list"] = C.BOOL_TRUE | 41 extra["labels_as_list"] = C.BOOL_TRUE |
42 | 42 |
43 tickets, metadata = yield self.host.bridgeCall( | 43 tickets, metadata = yield self.host.bridgeCall( |
44 "ticketsGet", | 44 "ticketsGet", |
45 service.full() if service else u"", | 45 service.full() if service else "", |
46 node, | 46 node, |
47 C.NO_LIMIT, | 47 C.NO_LIMIT, |
48 [], | 48 [], |
49 "", | 49 "", |
50 extra, | 50 extra, |
51 profile, | 51 profile, |
52 ) | 52 ) |
53 template_data[u"tickets"] = [template_xmlui.create(self.host, x) for x in tickets] | 53 template_data["tickets"] = [template_xmlui.create(self.host, x) for x in tickets] |
54 template_data[u"on_ticket_click"] = data_objects.OnClick( | 54 template_data["on_ticket_click"] = data_objects.OnClick( |
55 url=self.getSubPageURL(request, u"tickets_view") + u"/{item.id}" | 55 url=self.getSubPageURL(request, "tickets_view") + "/{item.id}" |
56 ) | 56 ) |
57 metadata = data_objects.parsePubSubMetadata(metadata, tickets) | 57 metadata = data_objects.parsePubSubMetadata(metadata, tickets) |
58 self.setPagination(request, metadata) | 58 self.setPagination(request, metadata) |