comparison libervia/pages/merge-requests/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"merge-requests" 13 name = "merge-requests"
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"merge-requests_disco", request) 23 self.pageRedirect("merge-requests_disco", request)
24 if node == u"@": 24 if node == "@":
25 node = data[u"node"] = u"" 25 node = data["node"] = ""
26 self.checkCache( 26 self.checkCache(
27 request, C.CACHE_PUBSUB, service=service, node=node, short="merge-requests" 27 request, C.CACHE_PUBSUB, service=service, node=node, short="merge-requests"
28 ) 28 )
29 template_data = request.template_data 29 template_data = request.template_data
30 template_data[u"url_tickets_list"] = self.getPageByName("merge-requests").getURL( 30 template_data["url_tickets_list"] = self.getPageByName("merge-requests").getURL(
31 service.full(), node 31 service.full(), node
32 ) 32 )
33 template_data[u"url_tickets_new"] = self.getSubPageURL(request, "merge-requests_new") 33 template_data["url_tickets_new"] = self.getSubPageURL(request, "merge-requests_new")
34 34
35 35
36 @defer.inlineCallbacks 36 @defer.inlineCallbacks
37 def prepare_render(self, request): 37 def prepare_render(self, request):
38 data = self.getRData(request) 38 data = self.getRData(request)
39 template_data = request.template_data 39 template_data = request.template_data
40 service, node = data[u"service"], data[u"node"] 40 service, node = data["service"], data["node"]
41 profile = self.getProfile(request) or C.SERVICE_PROFILE 41 profile = self.getProfile(request) or C.SERVICE_PROFILE
42 42
43 merge_requests = yield self.host.bridgeCall( 43 merge_requests = yield self.host.bridgeCall(
44 "mergeRequestsGet", 44 "mergeRequestsGet",
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 {"labels_as_list": C.BOOL_TRUE}, 50 {"labels_as_list": C.BOOL_TRUE},
51 profile, 51 profile,
52 ) 52 )
53 template_data[u"tickets"] = [ 53 template_data["tickets"] = [
54 template_xmlui.create(self.host, x) for x in merge_requests[0] 54 template_xmlui.create(self.host, x) for x in merge_requests[0]
55 ] 55 ]
56 template_data[u"on_ticket_click"] = data_objects.OnClick( 56 template_data["on_ticket_click"] = data_objects.OnClick(
57 url=self.getSubPageURL(request, u"merge-requests_view") + u"/{item.id}" 57 url=self.getSubPageURL(request, "merge-requests_view") + "/{item.id}"
58 ) 58 )