comparison libervia/web/pages/lists/create/page_meta.py @ 1518:eb00d593801d

refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
author Goffi <goffi@goffi.org>
date Fri, 02 Jun 2023 16:49:28 +0200
parents libervia/pages/lists/create/page_meta.py@106bae41f5c8
children
comparison
equal deleted inserted replaced
1517:b8ed9726525b 1518:eb00d593801d
1 #!/usr/bin/env python3
2
3 from libervia.web.server.constants import Const as C
4 from libervia.backend.tools.common import data_format
5 from libervia.backend.core.log import getLogger
6
7 log = getLogger(__name__)
8
9 name = "list_create"
10 access = C.PAGES_ACCESS_PROFILE
11 template = "list/create.html"
12
13
14 def parse_url(self, request):
15 self.get_path_args(request, ["template_id"])
16 data = self.get_r_data(request)
17 if data["template_id"]:
18 self.http_redirect(
19 request,
20 self.get_page_by_name("list_create_from_tpl").get_url(data["template_id"])
21 )
22
23
24 async def prepare_render(self, request):
25 template_data = request.template_data
26 profile = self.get_profile(request)
27 tpl_raw = await self.host.bridge_call(
28 "list_templates_names_get",
29 "",
30 profile,
31 )
32 lists_templates = data_format.deserialise(tpl_raw, type_check=list)
33 template_data["icons_names"] = {tpl['icon'] for tpl in lists_templates}
34 template_data["lists_templates"] = [
35 {
36 "icon": tpl["icon"],
37 "name": tpl["name"],
38 "url": self.get_url(tpl["id"]),
39 }
40 for tpl in lists_templates
41 ]