comparison libervia/pages/lists/view/page_meta.py @ 1395:4ccf42d8aab7

browser (lists/view): `grocery` list specialised behaviour: if the list is a `grocery` list, user can change status directly in list view, delete an item, and do a quick item creation without having to use the `create` button.
author Goffi <goffi@goffi.org>
date Sat, 27 Feb 2021 21:08:42 +0100
parents ac4173fff71d
children d62df81440c6 915c7c2f1729
comparison
equal deleted inserted replaced
1394:72f9639594b2 1395:4ccf42d8aab7
117 lists_ns=self.host.ns_map["tickets"], 117 lists_ns=self.host.ns_map["tickets"],
118 pubsub_service=service.full(), 118 pubsub_service=service.full(),
119 pubsub_node=node, 119 pubsub_node=node,
120 list_type=list_type, 120 list_type=list_type,
121 ) 121 )
122
123
124 async def on_data_post(self, request):
125 data = self.getRData(request)
126 profile = self.getProfile(request)
127 service = data["service"]
128 node = data["node"]
129 list_type = self.getPostedData(request, ("type",))
130 if list_type == "grocery":
131 name, quantity = self.getPostedData(request, ("name", "quantity"))
132 if not name:
133 self.pageError(request, C.HTTP_BAD_REQUEST)
134 item_data = {
135 "name": [name],
136 }
137 if quantity:
138 item_data["quantity"] = [quantity]
139 await self.host.bridgeCall(
140 "listSet", service.full(), node, item_data, "", "", "", profile
141 )
142 return C.POST_NO_CONFIRM
143 else:
144 raise NotImplementedError(
145 f"Can't use quick list item set for list of type {list_type!r}"
146 )