comparison libervia/pages/lists/page_meta.py @ 1378:e3e303a30a74

pages (tickets): renamed "tickets" to "lists": "lists" is more generic, and tickets is actually a specific kind of list. /!\ "tickets_trackers_json" option has been renamed to "lists_directory_json".
author Goffi <goffi@goffi.org>
date Thu, 28 Jan 2021 18:51:44 +0100
parents libervia/pages/tickets/page_meta.py@46ce79eac754
children
comparison
equal deleted inserted replaced
1377:46ce79eac754 1378:e3e303a30a74
1 #!/usr/bin/env python3
2
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
6 from sat.tools.common import data_format
7 from sat.core.log import getLogger
8
9 log = getLogger(__name__)
10
11 name = "lists"
12 access = C.PAGES_ACCESS_PUBLIC
13 template = "list/overview.html"
14
15
16 def parse_url(self, request):
17 self.getPathArgs(request, ["service", "node"], service="jid")
18 data = self.getRData(request)
19 service, node = data["service"], data["node"]
20 if node is None:
21 self.pageRedirect("lists_disco", request)
22 if node == "@":
23 node = data["node"] = ""
24 template_data = request.template_data
25 template_data["url_list_items"] = self.getURL(service.full(), node or "@")
26 template_data["url_list_new"] = self.getSubPageURL(request, "list_new")
27
28
29 async def prepare_render(self, request):
30 data = self.getRData(request)
31 template_data = request.template_data
32 service, node = data["service"], data["node"]
33 profile = self.getProfile(request) or C.SERVICE_PROFILE
34
35 self.checkCache(request, C.CACHE_PUBSUB, service=service, node=node, short="tickets")
36
37 extra = self.getPubsubExtra(request)
38 extra["labels_as_list"] = C.BOOL_TRUE
39 self.handleSearch(request, extra)
40
41 list_raw = await self.host.bridgeCall(
42 "listGet",
43 service.full() if service else "",
44 node,
45 C.NO_LIMIT,
46 [],
47 "",
48 extra,
49 profile,
50 )
51 list_items, metadata = data_format.deserialise(list_raw, type_check=list)
52 template_data["list_items"] = [
53 template_xmlui.create(self.host, x) for x in list_items
54 ]
55 template_data["on_list_item_click"] = data_objects.OnClick(
56 url=self.getSubPageURL(request, "list_view") + "/{item.id}"
57 )
58 self.setPagination(request, metadata)