diff libervia/pages/lists/new/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 diff
--- a/libervia/pages/lists/new/page_meta.py	Sat Feb 20 13:58:42 2021 +0100
+++ b/libervia/pages/lists/new/page_meta.py	Sat Feb 20 14:07:22 2021 +0100
@@ -12,6 +12,9 @@
 template = "list/create_item.html"
 
 
+def parse_url(self, request):
+    self.getPathArgs(request, ["service", "node"], service="jid", node="@")
+
 async def prepare_render(self, request):
     data = self.getRData(request)
     template_data = request.template_data
@@ -38,13 +41,17 @@
     except KeyError:
         pass
 
-    # same as for list_edit, we have to convert for now
-    wid = xmlui_obj.widgets['body']
-    if wid.type == "xhtmlbox":
-        wid.type = "textbox"
-        wid.value =  await self.host.bridgeCall(
-            "syntaxConvert", wid.value, C.SYNTAX_XHTML, "markdown",
-            False, profile)
+    try:
+        wid = xmlui_obj.widgets['body']
+    except KeyError:
+        pass
+    else:
+        if wid.type == "xhtmlbox":
+            # same as for list_edit, we have to convert for now
+            wid.type = "textbox"
+            wid.value =  await self.host.bridgeCall(
+                "syntaxConvert", wid.value, C.SYNTAX_XHTML, "markdown",
+                False, profile)
     template_data["new_list_item_xmlui"] = xmlui_obj
 
 
@@ -53,7 +60,8 @@
     service = data["service"]
     node = data["node"]
     posted_data = self.getAllPostedData(request)
-    if not posted_data["title"] or not posted_data["body"]:
+    if (("title" in posted_data and not posted_data["title"])
+         or ("body" in posted_data and not posted_data["body"])):
         self.pageError(request, C.HTTP_BAD_REQUEST)
     try:
         posted_data["labels"] = [l.strip() for l in posted_data["labels"][0].split(",")]
@@ -62,10 +70,11 @@
     profile = self.getProfile(request)
 
     # we convert back body to XHTML
-    body = await self.host.bridgeCall(
-        "syntaxConvert", posted_data['body'][0], "markdown", C.SYNTAX_XHTML,
-        False, profile)
-    posted_data['body'] = ['<div xmlns="{ns}">{body}</div>'.format(ns=C.NS_XHTML,
+    if "body" in posted_data:
+        body = await self.host.bridgeCall(
+            "syntaxConvert", posted_data['body'][0], "markdown", C.SYNTAX_XHTML,
+            False, profile)
+        posted_data['body'] = ['<div xmlns="{ns}">{body}</div>'.format(ns=C.NS_XHTML,
                                                                      body=body)]