comparison libervia/pages/lists/create/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
children a84383c659b4
comparison
equal deleted inserted replaced
1377:46ce79eac754 1378:e3e303a30a74
1 #!/usr/bin/env python3
2
3
4 from libervia.server.constants import Const as C
5 from sat.tools.common import template_xmlui
6 from sat.tools.common import data_objects
7 from sat.tools.common import data_format
8 from sat.core.log import getLogger
9
10 log = getLogger(__name__)
11
12 name = "list_create"
13 access = C.PAGES_ACCESS_PUBLIC
14 template = "list/overview.html"
15
16
17 def parse_url(self, request):
18 self.getPathArgs(request, ["service", "node"], service="jid")
19 data = self.getRData(request)
20 service, node = data["service"], data["node"]
21 if node is None:
22 self.pageRedirect("lists_disco", request)
23 if node == "@":
24 node = data["node"] = ""
25 template_data = request.template_data
26 template_data["url_list_items"] = self.getURL(service.full(), node or "@")
27 template_data["url_list_new"] = self.getSubPageURL(request, "list_new")
28
29
30 async def prepare_render(self, request):
31 data = self.getRData(request)
32 template_data = request.template_data
33 service, node = data["service"], data["node"]
34 profile = self.getProfile(request) or C.SERVICE_PROFILE
35
36 self.checkCache(request, C.CACHE_PUBSUB, service=service, node=node, short="tickets")
37
38 extra = self.getPubsubExtra(request)
39 extra["labels_as_list"] = C.BOOL_TRUE
40 self.handleSearch(request, extra)
41
42 list_data_raw = await self.host.bridgeCall(
43 "listGet",
44 service.full() if service else "",
45 node,
46 C.NO_LIMIT,
47 [],
48 "",
49 extra,
50 profile,
51 )
52 list_items, metadata = data_format.deserialise(list_data_raw, type_check=list)
53 template_data["list_items"] = [template_xmlui.create(self.host, x) for x in
54 list_items]
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)