annotate libervia/web/pages/lists/view/page_meta.py @ 1530:b338c31d5251

browser: integrate the `jid` module
author Goffi <goffi@goffi.org>
date Thu, 08 Jun 2023 23:32:47 +0200
parents eb00d593801d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
1 #!/usr/bin/env python3
1239
f511f8fbbf8a fixed shebangs
Goffi <goffi@goffi.org>
parents: 1216
diff changeset
2
1518
eb00d593801d refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
Goffi <goffi@goffi.org>
parents: 1509
diff changeset
3 from libervia.backend.tools.common import template_xmlui
eb00d593801d refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
Goffi <goffi@goffi.org>
parents: 1509
diff changeset
4 from libervia.backend.tools.common import data_objects
eb00d593801d refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
Goffi <goffi@goffi.org>
parents: 1509
diff changeset
5 from libervia.backend.tools.common import data_format
eb00d593801d refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
Goffi <goffi@goffi.org>
parents: 1509
diff changeset
6 from libervia.backend.core.log import getLogger
eb00d593801d refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
Goffi <goffi@goffi.org>
parents: 1509
diff changeset
7 from libervia.frontends.bridge.bridge_frontend import BridgeException
eb00d593801d refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
Goffi <goffi@goffi.org>
parents: 1509
diff changeset
8 from libervia.web.server.constants import Const as C
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1089
diff changeset
9
1145
29eb15062416 pages: set __name__ for imported pages
Goffi <goffi@goffi.org>
parents: 1142
diff changeset
10 log = getLogger(__name__)
967
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
11
1378
e3e303a30a74 pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents: 1377
diff changeset
12 name = "lists"
967
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 access = C.PAGES_ACCESS_PUBLIC
1378
e3e303a30a74 pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents: 1377
diff changeset
14 template = "list/overview.html"
967
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
15
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
16
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 def parse_url(self, request):
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
18 self.get_path_args(request, ["service", "node"], service="jid")
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
19 data = self.get_r_data(request)
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
20 service, node = data["service"], data["node"]
1078
296bda6b7ed0 pages (tickets): tickets discovery:
Goffi <goffi@goffi.org>
parents: 1043
diff changeset
21 if node is None:
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
22 self.http_redirect(request, self.get_page_by_name("lists_disco").url)
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
23 if node == "@":
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
24 node = data["node"] = ""
973
2e75dc986e03 pages (tickets): URLs for list and new are set in the template for the whole subhierarchy
Goffi <goffi@goffi.org>
parents: 967
diff changeset
25 template_data = request.template_data
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
26 template_data["url_list_items"] = self.get_url(service.full(), node or "@")
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
27 template_data["url_list_new"] = self.get_page_by_name("list_new").get_url(
1387
a84383c659b4 lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents: 1378
diff changeset
28 service.full(), node or "@")
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1089
diff changeset
29
967
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
30
1302
04e7dd6b6f4d pages (blog, tickets, merge-requests): updated code to handle new serialisation, following backend changes
Goffi <goffi@goffi.org>
parents: 1239
diff changeset
31 async def prepare_render(self, request):
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
32 data = self.get_r_data(request)
967
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
33 template_data = request.template_data
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
34 service, node = data["service"], data["node"]
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
35 submitted_node = await self.host.bridge_call(
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
36 "ps_schema_submitted_node_get",
1472
915c7c2f1729 pages (lists/view): fix node name following use of XEP-0346
Goffi <goffi@goffi.org>
parents: 1395
diff changeset
37 node or self.host.ns_map["tickets"]
915c7c2f1729 pages (lists/view): fix node name following use of XEP-0346
Goffi <goffi@goffi.org>
parents: 1395
diff changeset
38 )
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
39 profile = self.get_profile(request) or C.SERVICE_PROFILE
967
4d1dcf97740f pages (tickets): tickets first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
40
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
41 self.check_cache(request, C.CACHE_PUBSUB, service=service, node=node, short="tickets")
1021
b39c527f208c pages (tickets): check cache in prepare_render instead of parse_url
Goffi <goffi@goffi.org>
parents: 1007
diff changeset
42
1389
ac4173fff71d pages (lists/view): add `list_type` to `template_data`:
Goffi <goffi@goffi.org>
parents: 1387
diff changeset
43 try:
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
44 lists_types = self.get_page_data(request, "lists_types")
1389
ac4173fff71d pages (lists/view): add `list_type` to `template_data`:
Goffi <goffi@goffi.org>
parents: 1387
diff changeset
45 if lists_types is None:
ac4173fff71d pages (lists/view): add `list_type` to `template_data`:
Goffi <goffi@goffi.org>
parents: 1387
diff changeset
46 lists_types = {}
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
47 self.set_page_data(request, "lists_types", lists_types)
1389
ac4173fff71d pages (lists/view): add `list_type` to `template_data`:
Goffi <goffi@goffi.org>
parents: 1387
diff changeset
48 list_type = lists_types[(service, node)]
ac4173fff71d pages (lists/view): add `list_type` to `template_data`:
Goffi <goffi@goffi.org>
parents: 1387
diff changeset
49 except KeyError:
ac4173fff71d pages (lists/view): add `list_type` to `template_data`:
Goffi <goffi@goffi.org>
parents: 1387
diff changeset
50 ns_tickets_type = self.host.ns_map["tickets_type"]
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
51 schema_raw = await self.host.bridge_call(
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
52 "ps_schema_dict_get",
1389
ac4173fff71d pages (lists/view): add `list_type` to `template_data`:
Goffi <goffi@goffi.org>
parents: 1387
diff changeset
53 service.full(),
1472
915c7c2f1729 pages (lists/view): fix node name following use of XEP-0346
Goffi <goffi@goffi.org>
parents: 1395
diff changeset
54 submitted_node,
1389
ac4173fff71d pages (lists/view): add `list_type` to `template_data`:
Goffi <goffi@goffi.org>
parents: 1387
diff changeset
55 profile
ac4173fff71d pages (lists/view): add `list_type` to `template_data`:
Goffi <goffi@goffi.org>
parents: 1387
diff changeset
56 )
ac4173fff71d pages (lists/view): add `list_type` to `template_data`:
Goffi <goffi@goffi.org>
parents: 1387
diff changeset
57 schema = data_format.deserialise(schema_raw)
ac4173fff71d pages (lists/view): add `list_type` to `template_data`:
Goffi <goffi@goffi.org>
parents: 1387
diff changeset
58 try:
ac4173fff71d pages (lists/view): add `list_type` to `template_data`:
Goffi <goffi@goffi.org>
parents: 1387
diff changeset
59 list_type_field = next(
ac4173fff71d pages (lists/view): add `list_type` to `template_data`:
Goffi <goffi@goffi.org>
parents: 1387
diff changeset
60 f for f in schema["fields"] if f["type"] == "hidden"
ac4173fff71d pages (lists/view): add `list_type` to `template_data`:
Goffi <goffi@goffi.org>
parents: 1387
diff changeset
61 and f.get("name") == ns_tickets_type
ac4173fff71d pages (lists/view): add `list_type` to `template_data`:
Goffi <goffi@goffi.org>
parents: 1387
diff changeset
62 )
ac4173fff71d pages (lists/view): add `list_type` to `template_data`:
Goffi <goffi@goffi.org>
parents: 1387
diff changeset
63 except StopIteration:
ac4173fff71d pages (lists/view): add `list_type` to `template_data`:
Goffi <goffi@goffi.org>
parents: 1387
diff changeset
64 list_type = lists_types[(service, node)] = None
ac4173fff71d pages (lists/view): add `list_type` to `template_data`:
Goffi <goffi@goffi.org>
parents: 1387
diff changeset
65 else:
ac4173fff71d pages (lists/view): add `list_type` to `template_data`:
Goffi <goffi@goffi.org>
parents: 1387
diff changeset
66 if list_type_field.get("value") is None:
ac4173fff71d pages (lists/view): add `list_type` to `template_data`:
Goffi <goffi@goffi.org>
parents: 1387
diff changeset
67 list_type = None
ac4173fff71d pages (lists/view): add `list_type` to `template_data`:
Goffi <goffi@goffi.org>
parents: 1387
diff changeset
68 else:
ac4173fff71d pages (lists/view): add `list_type` to `template_data`:
Goffi <goffi@goffi.org>
parents: 1387
diff changeset
69 list_type = list_type_field["value"].lower().strip()
ac4173fff71d pages (lists/view): add `list_type` to `template_data`:
Goffi <goffi@goffi.org>
parents: 1387
diff changeset
70 lists_types[(service, node)] = list_type
ac4173fff71d pages (lists/view): add `list_type` to `template_data`:
Goffi <goffi@goffi.org>
parents: 1387
diff changeset
71
ac4173fff71d pages (lists/view): add `list_type` to `template_data`:
Goffi <goffi@goffi.org>
parents: 1387
diff changeset
72 data["list_type"] = template_data["list_type"] = list_type
ac4173fff71d pages (lists/view): add `list_type` to `template_data`:
Goffi <goffi@goffi.org>
parents: 1387
diff changeset
73
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
74 extra = self.get_pubsub_extra(request)
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
75 extra["labels_as_list"] = C.BOOL_TRUE
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
76 self.handle_search(request, extra)
1142
003597f895a0 pages (tickets): use the new getPubsubExtra and setPagination methods to handle pagination
Goffi <goffi@goffi.org>
parents: 1137
diff changeset
77
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
78 list_raw = await self.host.bridge_call(
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
79 "list_get",
1216
b2d067339de3 python 3 port:
Goffi <goffi@goffi.org>
parents: 1145
diff changeset
80 service.full() if service else "",
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1089
diff changeset
81 node,
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1089
diff changeset
82 C.NO_LIMIT,
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1089
diff changeset
83 [],
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1089
diff changeset
84 "",
1453
d62df81440c6 pages (lists/view): fix serialisation of `extra` when calling `listGet`
Goffi <goffi@goffi.org>
parents: 1395
diff changeset
85 data_format.serialise(extra),
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1089
diff changeset
86 profile,
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1089
diff changeset
87 )
1387
a84383c659b4 lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents: 1378
diff changeset
88 if profile != C.SERVICE_PROFILE:
a84383c659b4 lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents: 1378
diff changeset
89 try:
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
90 affiliations = await self.host.bridge_call(
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
91 "ps_node_affiliations_get",
1387
a84383c659b4 lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents: 1378
diff changeset
92 service.full() if service else "",
1472
915c7c2f1729 pages (lists/view): fix node name following use of XEP-0346
Goffi <goffi@goffi.org>
parents: 1395
diff changeset
93 submitted_node,
1387
a84383c659b4 lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents: 1378
diff changeset
94 profile
a84383c659b4 lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents: 1378
diff changeset
95 )
a84383c659b4 lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents: 1378
diff changeset
96 except BridgeException as e:
1472
915c7c2f1729 pages (lists/view): fix node name following use of XEP-0346
Goffi <goffi@goffi.org>
parents: 1395
diff changeset
97 log.warning(
915c7c2f1729 pages (lists/view): fix node name following use of XEP-0346
Goffi <goffi@goffi.org>
parents: 1395
diff changeset
98 f"Can't get affiliations for node {submitted_node!r} at {service}: {e}"
915c7c2f1729 pages (lists/view): fix node name following use of XEP-0346
Goffi <goffi@goffi.org>
parents: 1395
diff changeset
99 )
1387
a84383c659b4 lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents: 1378
diff changeset
100 template_data["owner"] = False
a84383c659b4 lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents: 1378
diff changeset
101 else:
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
102 is_owner = affiliations.get(self.get_jid(request).userhost()) == 'owner'
1387
a84383c659b4 lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents: 1378
diff changeset
103 template_data["owner"] = is_owner
a84383c659b4 lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents: 1378
diff changeset
104 if is_owner:
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
105 self.expose_to_scripts(
1387
a84383c659b4 lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents: 1378
diff changeset
106 request,
a84383c659b4 lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents: 1378
diff changeset
107 affiliations={str(e): str(a) for e, a in affiliations.items()}
a84383c659b4 lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents: 1378
diff changeset
108 )
a84383c659b4 lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents: 1378
diff changeset
109 else:
a84383c659b4 lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents: 1378
diff changeset
110 template_data["owner"] = False
a84383c659b4 lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents: 1378
diff changeset
111
1378
e3e303a30a74 pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents: 1377
diff changeset
112 list_items, metadata = data_format.deserialise(list_raw, type_check=list)
e3e303a30a74 pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents: 1377
diff changeset
113 template_data["list_items"] = [
e3e303a30a74 pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents: 1377
diff changeset
114 template_xmlui.create(self.host, x) for x in list_items
e3e303a30a74 pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents: 1377
diff changeset
115 ]
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
116 view_url = self.get_page_by_name('list_view').get_url(service.full(), node or '@')
1378
e3e303a30a74 pages (tickets): renamed "tickets" to "lists":
Goffi <goffi@goffi.org>
parents: 1377
diff changeset
117 template_data["on_list_item_click"] = data_objects.OnClick(
1387
a84383c659b4 lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents: 1378
diff changeset
118 url=f"{view_url}/{{item.id}}"
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1089
diff changeset
119 )
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
120 self.set_pagination(request, metadata)
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
121 self.expose_to_scripts(
1387
a84383c659b4 lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents: 1378
diff changeset
122 request,
a84383c659b4 lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents: 1378
diff changeset
123 lists_ns=self.host.ns_map["tickets"],
a84383c659b4 lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents: 1378
diff changeset
124 pubsub_service=service.full(),
a84383c659b4 lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents: 1378
diff changeset
125 pubsub_node=node,
1389
ac4173fff71d pages (lists/view): add `list_type` to `template_data`:
Goffi <goffi@goffi.org>
parents: 1387
diff changeset
126 list_type=list_type,
1387
a84383c659b4 lists: creation, invitation, item deletion:
Goffi <goffi@goffi.org>
parents: 1378
diff changeset
127 )
1395
4ccf42d8aab7 browser (lists/view): `grocery` list specialised behaviour:
Goffi <goffi@goffi.org>
parents: 1389
diff changeset
128
4ccf42d8aab7 browser (lists/view): `grocery` list specialised behaviour:
Goffi <goffi@goffi.org>
parents: 1389
diff changeset
129
4ccf42d8aab7 browser (lists/view): `grocery` list specialised behaviour:
Goffi <goffi@goffi.org>
parents: 1389
diff changeset
130 async def on_data_post(self, request):
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
131 data = self.get_r_data(request)
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
132 profile = self.get_profile(request)
1395
4ccf42d8aab7 browser (lists/view): `grocery` list specialised behaviour:
Goffi <goffi@goffi.org>
parents: 1389
diff changeset
133 service = data["service"]
4ccf42d8aab7 browser (lists/view): `grocery` list specialised behaviour:
Goffi <goffi@goffi.org>
parents: 1389
diff changeset
134 node = data["node"]
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
135 list_type = self.get_posted_data(request, ("type",))
1395
4ccf42d8aab7 browser (lists/view): `grocery` list specialised behaviour:
Goffi <goffi@goffi.org>
parents: 1389
diff changeset
136 if list_type == "grocery":
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
137 name, quantity = self.get_posted_data(request, ("name", "quantity"))
1395
4ccf42d8aab7 browser (lists/view): `grocery` list specialised behaviour:
Goffi <goffi@goffi.org>
parents: 1389
diff changeset
138 if not name:
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
139 self.page_error(request, C.HTTP_BAD_REQUEST)
1395
4ccf42d8aab7 browser (lists/view): `grocery` list specialised behaviour:
Goffi <goffi@goffi.org>
parents: 1389
diff changeset
140 item_data = {
4ccf42d8aab7 browser (lists/view): `grocery` list specialised behaviour:
Goffi <goffi@goffi.org>
parents: 1389
diff changeset
141 "name": [name],
4ccf42d8aab7 browser (lists/view): `grocery` list specialised behaviour:
Goffi <goffi@goffi.org>
parents: 1389
diff changeset
142 }
4ccf42d8aab7 browser (lists/view): `grocery` list specialised behaviour:
Goffi <goffi@goffi.org>
parents: 1389
diff changeset
143 if quantity:
4ccf42d8aab7 browser (lists/view): `grocery` list specialised behaviour:
Goffi <goffi@goffi.org>
parents: 1389
diff changeset
144 item_data["quantity"] = [quantity]
1509
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
145 await self.host.bridge_call(
106bae41f5c8 massive refactoring from camelCase -> snake_case. See backend commit log for more details
Goffi <goffi@goffi.org>
parents: 1483
diff changeset
146 "list_set", service.full(), node, item_data, "", "", "", profile
1395
4ccf42d8aab7 browser (lists/view): `grocery` list specialised behaviour:
Goffi <goffi@goffi.org>
parents: 1389
diff changeset
147 )
4ccf42d8aab7 browser (lists/view): `grocery` list specialised behaviour:
Goffi <goffi@goffi.org>
parents: 1389
diff changeset
148 return C.POST_NO_CONFIRM
4ccf42d8aab7 browser (lists/view): `grocery` list specialised behaviour:
Goffi <goffi@goffi.org>
parents: 1389
diff changeset
149 else:
4ccf42d8aab7 browser (lists/view): `grocery` list specialised behaviour:
Goffi <goffi@goffi.org>
parents: 1389
diff changeset
150 raise NotImplementedError(
4ccf42d8aab7 browser (lists/view): `grocery` list specialised behaviour:
Goffi <goffi@goffi.org>
parents: 1389
diff changeset
151 f"Can't use quick list item set for list of type {list_type!r}"
4ccf42d8aab7 browser (lists/view): `grocery` list specialised behaviour:
Goffi <goffi@goffi.org>
parents: 1389
diff changeset
152 )