Mercurial > libervia-web
annotate libervia/pages/lists/page_meta.py @ 1384:b61509c47cac
tasks (brython): fixed Brython scripts during dev mode reload
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 20 Feb 2021 13:56:08 +0100 |
parents | e3e303a30a74 |
children |
rev | line source |
---|---|
1216 | 1 #!/usr/bin/env python3 |
1239 | 2 |
967 | 3 from libervia.server.constants import Const as C |
4 from sat.tools.common import template_xmlui | |
5 from sat.tools.common import data_objects | |
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 |
967 | 7 from sat.core.log import getLogger |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1089
diff
changeset
|
8 |
1145
29eb15062416
pages: set __name__ for imported pages
Goffi <goffi@goffi.org>
parents:
1142
diff
changeset
|
9 log = getLogger(__name__) |
967 | 10 |
1378
e3e303a30a74
pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents:
1377
diff
changeset
|
11 name = "lists" |
967 | 12 access = C.PAGES_ACCESS_PUBLIC |
1378
e3e303a30a74
pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents:
1377
diff
changeset
|
13 template = "list/overview.html" |
967 | 14 |
15 | |
16 def parse_url(self, request): | |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1089
diff
changeset
|
17 self.getPathArgs(request, ["service", "node"], service="jid") |
1078
296bda6b7ed0
pages (tickets): tickets discovery:
Goffi <goffi@goffi.org>
parents:
1043
diff
changeset
|
18 data = self.getRData(request) |
1216 | 19 service, node = data["service"], data["node"] |
1078
296bda6b7ed0
pages (tickets): tickets discovery:
Goffi <goffi@goffi.org>
parents:
1043
diff
changeset
|
20 if node is None: |
1378
e3e303a30a74
pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents:
1377
diff
changeset
|
21 self.pageRedirect("lists_disco", request) |
1216 | 22 if node == "@": |
23 node = data["node"] = "" | |
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
|
24 template_data = request.template_data |
1378
e3e303a30a74
pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents:
1377
diff
changeset
|
25 template_data["url_list_items"] = self.getURL(service.full(), node or "@") |
e3e303a30a74
pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents:
1377
diff
changeset
|
26 template_data["url_list_new"] = self.getSubPageURL(request, "list_new") |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1089
diff
changeset
|
27 |
967 | 28 |
1302
04e7dd6b6f4d
pages (blog, tickets, merge-requests): updated code to handle new serialisation, following backend changes
Goffi <goffi@goffi.org>
parents:
1239
diff
changeset
|
29 async def prepare_render(self, request): |
967 | 30 data = self.getRData(request) |
31 template_data = request.template_data | |
1216 | 32 service, node = data["service"], data["node"] |
967 | 33 profile = self.getProfile(request) or C.SERVICE_PROFILE |
34 | |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1089
diff
changeset
|
35 self.checkCache(request, C.CACHE_PUBSUB, service=service, node=node, short="tickets") |
1021
b39c527f208c
pages (tickets): check cache in prepare_render instead of parse_url
Goffi <goffi@goffi.org>
parents:
1007
diff
changeset
|
36 |
1142
003597f895a0
pages (tickets): use the new getPubsubExtra and setPagination methods to handle pagination
Goffi <goffi@goffi.org>
parents:
1137
diff
changeset
|
37 extra = self.getPubsubExtra(request) |
1216 | 38 extra["labels_as_list"] = C.BOOL_TRUE |
1377
46ce79eac754
pages(tickets): add Full-Text Search
Goffi <goffi@goffi.org>
parents:
1302
diff
changeset
|
39 self.handleSearch(request, extra) |
1142
003597f895a0
pages (tickets): use the new getPubsubExtra and setPagination methods to handle pagination
Goffi <goffi@goffi.org>
parents:
1137
diff
changeset
|
40 |
1378
e3e303a30a74
pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents:
1377
diff
changeset
|
41 list_raw = await self.host.bridgeCall( |
e3e303a30a74
pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents:
1377
diff
changeset
|
42 "listGet", |
1216 | 43 service.full() if service else "", |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1089
diff
changeset
|
44 node, |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1089
diff
changeset
|
45 C.NO_LIMIT, |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1089
diff
changeset
|
46 [], |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1089
diff
changeset
|
47 "", |
1142
003597f895a0
pages (tickets): use the new getPubsubExtra and setPagination methods to handle pagination
Goffi <goffi@goffi.org>
parents:
1137
diff
changeset
|
48 extra, |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1089
diff
changeset
|
49 profile, |
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1089
diff
changeset
|
50 ) |
1378
e3e303a30a74
pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents:
1377
diff
changeset
|
51 list_items, metadata = data_format.deserialise(list_raw, type_check=list) |
e3e303a30a74
pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents:
1377
diff
changeset
|
52 template_data["list_items"] = [ |
e3e303a30a74
pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents:
1377
diff
changeset
|
53 template_xmlui.create(self.host, x) for x in list_items |
e3e303a30a74
pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents:
1377
diff
changeset
|
54 ] |
e3e303a30a74
pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents:
1377
diff
changeset
|
55 template_data["on_list_item_click"] = data_objects.OnClick( |
e3e303a30a74
pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents:
1377
diff
changeset
|
56 url=self.getSubPageURL(request, "list_view") + "/{item.id}" |
1113
cdd389ef97bc
server: code style reformatting using black
Goffi <goffi@goffi.org>
parents:
1089
diff
changeset
|
57 ) |
1142
003597f895a0
pages (tickets): use the new getPubsubExtra and setPagination methods to handle pagination
Goffi <goffi@goffi.org>
parents:
1137
diff
changeset
|
58 self.setPagination(request, metadata) |