view libervia/pages/lists/create/page_meta.py @ 1387:a84383c659b4

lists: creation, invitation, item deletion: this big patch includes: - reorganisation of pages for consistency, discovery is now the main list page, and list overview is now in `view` while item view is moved to `view_item` - lists from lists of interest are now shown in discovery page - list deletion from discory page - list can now be created, using templates now available from backend - invitation manager can now be used from list overview - list item can now be deleted from `view_item`
author Goffi <goffi@goffi.org>
date Sat, 20 Feb 2021 14:07:22 +0100
parents e3e303a30a74
children 106bae41f5c8
line wrap: on
line source

#!/usr/bin/env python3

from libervia.server.constants import Const as C
from sat.tools.common import data_format
from sat.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.getPathArgs(request, ["template_id"])
    data = self.getRData(request)
    if data["template_id"]:
        self.HTTPRedirect(
            request,
            self.getPageByName("list_create_from_tpl").getURL(data["template_id"])
        )


async def prepare_render(self, request):
    template_data = request.template_data
    profile = self.getProfile(request)
    tpl_raw = await self.host.bridgeCall(
        "listTemplatesNamesGet",
        "",
        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.getURL(tpl["id"]),
        }
        for tpl in lists_templates
    ]