comparison libervia/pages/lists/new/page_meta.py @ 1509:106bae41f5c8

massive refactoring from camelCase -> snake_case. See backend commit log for more details
author Goffi <goffi@goffi.org>
date Sat, 08 Apr 2023 13:44:11 +0200
parents a84383c659b4
children
comparison
equal deleted inserted replaced
1508:ec3ad9abf9f9 1509:106bae41f5c8
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 14
15 def parse_url(self, request): 15 def parse_url(self, request):
16 self.getPathArgs(request, ["service", "node"], service="jid", node="@") 16 self.get_path_args(request, ["service", "node"], service="jid", node="@")
17 17
18 async def prepare_render(self, request): 18 async def prepare_render(self, request):
19 data = self.getRData(request) 19 data = self.get_r_data(request)
20 template_data = request.template_data 20 template_data = request.template_data
21 service, node = data.get("service", ""), data.get("node", "") 21 service, node = data.get("service", ""), data.get("node", "")
22 profile = self.getProfile(request) 22 profile = self.get_profile(request)
23 schema = await self.host.bridgeCall("listSchemaGet", service.full(), node, profile) 23 schema = await self.host.bridge_call("list_schema_get", service.full(), node, profile)
24 data["schema"] = schema 24 data["schema"] = schema
25 # following fields are handled in backend 25 # following fields are handled in backend
26 ignore = ( 26 ignore = (
27 "author", 27 "author",
28 "author_jid", 28 "author_jid",
47 pass 47 pass
48 else: 48 else:
49 if wid.type == "xhtmlbox": 49 if wid.type == "xhtmlbox":
50 # same as for list_edit, we have to convert for now 50 # same as for list_edit, we have to convert for now
51 wid.type = "textbox" 51 wid.type = "textbox"
52 wid.value = await self.host.bridgeCall( 52 wid.value = await self.host.bridge_call(
53 "syntaxConvert", wid.value, C.SYNTAX_XHTML, "markdown", 53 "syntax_convert", wid.value, C.SYNTAX_XHTML, "markdown",
54 False, profile) 54 False, profile)
55 template_data["new_list_item_xmlui"] = xmlui_obj 55 template_data["new_list_item_xmlui"] = xmlui_obj
56 56
57 57
58 async def on_data_post(self, request): 58 async def on_data_post(self, request):
59 data = self.getRData(request) 59 data = self.get_r_data(request)
60 service = data["service"] 60 service = data["service"]
61 node = data["node"] 61 node = data["node"]
62 posted_data = self.getAllPostedData(request) 62 posted_data = self.get_all_posted_data(request)
63 if (("title" in posted_data and not posted_data["title"]) 63 if (("title" in posted_data and not posted_data["title"])
64 or ("body" in posted_data and not posted_data["body"])): 64 or ("body" in posted_data and not posted_data["body"])):
65 self.pageError(request, C.HTTP_BAD_REQUEST) 65 self.page_error(request, C.HTTP_BAD_REQUEST)
66 try: 66 try:
67 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(",")]
68 except (KeyError, IndexError): 68 except (KeyError, IndexError):
69 pass 69 pass
70 profile = self.getProfile(request) 70 profile = self.get_profile(request)
71 71
72 # we convert back body to XHTML 72 # we convert back body to XHTML
73 if "body" in posted_data: 73 if "body" in posted_data:
74 body = await self.host.bridgeCall( 74 body = await self.host.bridge_call(
75 "syntaxConvert", posted_data['body'][0], "markdown", C.SYNTAX_XHTML, 75 "syntax_convert", posted_data['body'][0], "markdown", C.SYNTAX_XHTML,
76 False, profile) 76 False, profile)
77 posted_data['body'] = ['<div xmlns="{ns}">{body}</div>'.format(ns=C.NS_XHTML, 77 posted_data['body'] = ['<div xmlns="{ns}">{body}</div>'.format(ns=C.NS_XHTML,
78 body=body)] 78 body=body)]
79 79
80 80
81 await self.host.bridgeCall( 81 await self.host.bridge_call(
82 "listSet", service.full(), node, posted_data, "", "", "", profile 82 "list_set", service.full(), node, posted_data, "", "", "", profile
83 ) 83 )
84 # we don't want to redirect to creation page on success, but to list overview 84 # we don't want to redirect to creation page on success, but to list overview
85 data["post_redirect_page"] = ( 85 data["post_redirect_page"] = (
86 self.getPageByName("lists"), 86 self.get_page_by_name("lists"),
87 service.full(), 87 service.full(),
88 node or "@", 88 node or "@",
89 ) 89 )