diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libervia/web/pages/lists/create/page_meta.py	Fri Jun 02 16:49:28 2023 +0200
@@ -0,0 +1,41 @@
+#!/usr/bin/env python3
+
+from libervia.web.server.constants import Const as C
+from libervia.backend.tools.common import data_format
+from libervia.backend.core.log import getLogger
+
+log = getLogger(__name__)
+
+name = "list_create"
+access = C.PAGES_ACCESS_PROFILE
+template = "list/create.html"
+
+
+def parse_url(self, request):
+    self.get_path_args(request, ["template_id"])
+    data = self.get_r_data(request)
+    if data["template_id"]:
+        self.http_redirect(
+            request,
+            self.get_page_by_name("list_create_from_tpl").get_url(data["template_id"])
+        )
+
+
+async def prepare_render(self, request):
+    template_data = request.template_data
+    profile = self.get_profile(request)
+    tpl_raw = await self.host.bridge_call(
+        "list_templates_names_get",
+        "",
+        profile,
+    )
+    lists_templates = data_format.deserialise(tpl_raw, type_check=list)
+    template_data["icons_names"] = {tpl['icon'] for tpl in lists_templates}
+    template_data["lists_templates"] = [
+        {
+            "icon": tpl["icon"],
+            "name": tpl["name"],
+            "url": self.get_url(tpl["id"]),
+        }
+        for tpl in lists_templates
+    ]