Mercurial > libervia-web
comparison 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 |
comparison
equal
deleted
inserted
replaced
1386:83be300d17e3 | 1387:a84383c659b4 |
---|---|
9 | 9 |
10 name = "list_new" | 10 name = "list_new" |
11 access = C.PAGES_ACCESS_PROFILE | 11 access = C.PAGES_ACCESS_PROFILE |
12 template = "list/create_item.html" | 12 template = "list/create_item.html" |
13 | 13 |
14 | |
15 def parse_url(self, request): | |
16 self.getPathArgs(request, ["service", "node"], service="jid", node="@") | |
14 | 17 |
15 async def prepare_render(self, request): | 18 async def prepare_render(self, request): |
16 data = self.getRData(request) | 19 data = self.getRData(request) |
17 template_data = request.template_data | 20 template_data = request.template_data |
18 service, node = data.get("service", ""), data.get("node", "") | 21 service, node = data.get("service", ""), data.get("node", "") |
36 # small trick to get a one line text input instead of the big textarea | 39 # small trick to get a one line text input instead of the big textarea |
37 xmlui_obj.widgets["labels"].type = "string" | 40 xmlui_obj.widgets["labels"].type = "string" |
38 except KeyError: | 41 except KeyError: |
39 pass | 42 pass |
40 | 43 |
41 # same as for list_edit, we have to convert for now | 44 try: |
42 wid = xmlui_obj.widgets['body'] | 45 wid = xmlui_obj.widgets['body'] |
43 if wid.type == "xhtmlbox": | 46 except KeyError: |
44 wid.type = "textbox" | 47 pass |
45 wid.value = await self.host.bridgeCall( | 48 else: |
46 "syntaxConvert", wid.value, C.SYNTAX_XHTML, "markdown", | 49 if wid.type == "xhtmlbox": |
47 False, profile) | 50 # same as for list_edit, we have to convert for now |
51 wid.type = "textbox" | |
52 wid.value = await self.host.bridgeCall( | |
53 "syntaxConvert", wid.value, C.SYNTAX_XHTML, "markdown", | |
54 False, profile) | |
48 template_data["new_list_item_xmlui"] = xmlui_obj | 55 template_data["new_list_item_xmlui"] = xmlui_obj |
49 | 56 |
50 | 57 |
51 async def on_data_post(self, request): | 58 async def on_data_post(self, request): |
52 data = self.getRData(request) | 59 data = self.getRData(request) |
53 service = data["service"] | 60 service = data["service"] |
54 node = data["node"] | 61 node = data["node"] |
55 posted_data = self.getAllPostedData(request) | 62 posted_data = self.getAllPostedData(request) |
56 if not posted_data["title"] or not posted_data["body"]: | 63 if (("title" in posted_data and not posted_data["title"]) |
64 or ("body" in posted_data and not posted_data["body"])): | |
57 self.pageError(request, C.HTTP_BAD_REQUEST) | 65 self.pageError(request, C.HTTP_BAD_REQUEST) |
58 try: | 66 try: |
59 posted_data["labels"] = [l.strip() for l in posted_data["labels"][0].split(",")] | 67 posted_data["labels"] = [l.strip() for l in posted_data["labels"][0].split(",")] |
60 except (KeyError, IndexError): | 68 except (KeyError, IndexError): |
61 pass | 69 pass |
62 profile = self.getProfile(request) | 70 profile = self.getProfile(request) |
63 | 71 |
64 # we convert back body to XHTML | 72 # we convert back body to XHTML |
65 body = await self.host.bridgeCall( | 73 if "body" in posted_data: |
66 "syntaxConvert", posted_data['body'][0], "markdown", C.SYNTAX_XHTML, | 74 body = await self.host.bridgeCall( |
67 False, profile) | 75 "syntaxConvert", posted_data['body'][0], "markdown", C.SYNTAX_XHTML, |
68 posted_data['body'] = ['<div xmlns="{ns}">{body}</div>'.format(ns=C.NS_XHTML, | 76 False, profile) |
77 posted_data['body'] = ['<div xmlns="{ns}">{body}</div>'.format(ns=C.NS_XHTML, | |
69 body=body)] | 78 body=body)] |
70 | 79 |
71 | 80 |
72 await self.host.bridgeCall( | 81 await self.host.bridgeCall( |
73 "listSet", service.full(), node, posted_data, "", "", "", profile | 82 "listSet", service.full(), node, posted_data, "", "", "", profile |