annotate libervia/pages/merge-requests/page_meta.py @ 1422:027f5059e1e2

pages (lists/view_item): browser part was not in the repository
author Goffi <goffi@goffi.org>
date Sat, 01 May 2021 19:05:05 +0200
parents e3e303a30a74
children ee1d31fe7cdf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
1 #!/usr/bin/env python3
1239
f511f8fbbf8a fixed shebangs
Goffi <goffi@goffi.org>
parents: 1216
diff changeset
2
991
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
3
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
4 from libervia.server.constants import Const as C
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
5 from sat.tools.common import template_xmlui
1302
04e7dd6b6f4d pages (blog, tickets, merge-requests): updated code to handle new serialisation, following backend changes
Goffi <goffi@goffi.org>
parents: 1239
diff changeset
6 from sat.tools.common import data_format
991
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
7 from sat.tools.common import data_objects
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
8 from sat.core.log import getLogger
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1098
diff changeset
9
1145
29eb15062416 pages: set __name__ for imported pages
Goffi <goffi@goffi.org>
parents: 1124
diff changeset
10 log = getLogger(__name__)
1378
e3e303a30a74 pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents: 1302
diff changeset
11
991
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
12
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
13 name = "merge-requests"
991
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
14 access = C.PAGES_ACCESS_PUBLIC
1378
e3e303a30a74 pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents: 1302
diff changeset
15 template = "list/overview.html"
991
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
16
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
17
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
18 def parse_url(self, request):
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1098
diff changeset
19 self.getPathArgs(request, ["service", "node"], service="jid")
1081
ed67265205c4 pages (merge-requests): added a discovery page similar to tickets one:
Goffi <goffi@goffi.org>
parents: 1043
diff changeset
20 data = self.getRData(request)
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
21 service, node = data["service"], data["node"]
1081
ed67265205c4 pages (merge-requests): added a discovery page similar to tickets one:
Goffi <goffi@goffi.org>
parents: 1043
diff changeset
22 if node is None:
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
23 self.pageRedirect("merge-requests_disco", request)
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
24 if node == "@":
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
25 node = data["node"] = ""
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1098
diff changeset
26 self.checkCache(
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1098
diff changeset
27 request, C.CACHE_PUBSUB, service=service, node=node, short="merge-requests"
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1098
diff changeset
28 )
991
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
29 template_data = request.template_data
1378
e3e303a30a74 pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents: 1302
diff changeset
30 template_data["url_list_items"] = self.getPageByName("merge-requests").getURL(
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1098
diff changeset
31 service.full(), node
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1098
diff changeset
32 )
1378
e3e303a30a74 pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents: 1302
diff changeset
33 template_data["url_list_new"] = self.getSubPageURL(request, "merge-requests_new")
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1098
diff changeset
34
991
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
35
1302
04e7dd6b6f4d pages (blog, tickets, merge-requests): updated code to handle new serialisation, following backend changes
Goffi <goffi@goffi.org>
parents: 1239
diff changeset
36 async def prepare_render(self, request):
991
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
37 data = self.getRData(request)
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
38 template_data = request.template_data
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
39 service, node = data["service"], data["node"]
991
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
40 profile = self.getProfile(request) or C.SERVICE_PROFILE
6ce9647011b3 pages(merge-requests): merge requests new, view and list pages implementations.
Goffi <goffi@goffi.org>
parents:
diff changeset
41
1302
04e7dd6b6f4d pages (blog, tickets, merge-requests): updated code to handle new serialisation, following backend changes
Goffi <goffi@goffi.org>
parents: 1239
diff changeset
42 merge_requests = data_format.deserialise(
04e7dd6b6f4d pages (blog, tickets, merge-requests): updated code to handle new serialisation, following backend changes
Goffi <goffi@goffi.org>
parents: 1239
diff changeset
43 await self.host.bridgeCall(
04e7dd6b6f4d pages (blog, tickets, merge-requests): updated code to handle new serialisation, following backend changes
Goffi <goffi@goffi.org>
parents: 1239
diff changeset
44 "mergeRequestsGet",
04e7dd6b6f4d pages (blog, tickets, merge-requests): updated code to handle new serialisation, following backend changes
Goffi <goffi@goffi.org>
parents: 1239
diff changeset
45 service.full() if service else "",
04e7dd6b6f4d pages (blog, tickets, merge-requests): updated code to handle new serialisation, following backend changes
Goffi <goffi@goffi.org>
parents: 1239
diff changeset
46 node,
04e7dd6b6f4d pages (blog, tickets, merge-requests): updated code to handle new serialisation, following backend changes
Goffi <goffi@goffi.org>
parents: 1239
diff changeset
47 C.NO_LIMIT,
04e7dd6b6f4d pages (blog, tickets, merge-requests): updated code to handle new serialisation, following backend changes
Goffi <goffi@goffi.org>
parents: 1239
diff changeset
48 [],
04e7dd6b6f4d pages (blog, tickets, merge-requests): updated code to handle new serialisation, following backend changes
Goffi <goffi@goffi.org>
parents: 1239
diff changeset
49 "",
04e7dd6b6f4d pages (blog, tickets, merge-requests): updated code to handle new serialisation, following backend changes
Goffi <goffi@goffi.org>
parents: 1239
diff changeset
50 {"labels_as_list": C.BOOL_TRUE},
04e7dd6b6f4d pages (blog, tickets, merge-requests): updated code to handle new serialisation, following backend changes
Goffi <goffi@goffi.org>
parents: 1239
diff changeset
51 profile,
04e7dd6b6f4d pages (blog, tickets, merge-requests): updated code to handle new serialisation, following backend changes
Goffi <goffi@goffi.org>
parents: 1239
diff changeset
52 )
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1098
diff changeset
53 )
1302
04e7dd6b6f4d pages (blog, tickets, merge-requests): updated code to handle new serialisation, following backend changes
Goffi <goffi@goffi.org>
parents: 1239
diff changeset
54
1378
e3e303a30a74 pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents: 1302
diff changeset
55 template_data["list_items"] = [
1302
04e7dd6b6f4d pages (blog, tickets, merge-requests): updated code to handle new serialisation, following backend changes
Goffi <goffi@goffi.org>
parents: 1239
diff changeset
56 template_xmlui.create(self.host, x) for x in merge_requests['items']
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1098
diff changeset
57 ]
1378
e3e303a30a74 pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents: 1302
diff changeset
58 template_data["on_list_item_click"] = data_objects.OnClick(
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
59 url=self.getSubPageURL(request, "merge-requests_view") + "/{item.id}"
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1098
diff changeset
60 )