Mercurial > libervia-backend
comparison libervia/backend/plugins/plugin_misc_lists.py @ 4271:a5d27f69eedb
plugin misc list: Comments node creation can now be specified with `comments` field in `extra`.
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 20 Jun 2024 14:36:09 +0200 |
parents | 0d7bb4df2343 |
children |
comparison
equal
deleted
inserted
replaced
4270:0d7bb4df2343 | 4271:a5d27f69eedb |
---|---|
320 - 'created' is set if item_id is None, i.e. if it's a new ticket | 320 - 'created' is set if item_id is None, i.e. if it's a new ticket |
321 - 'updated' is set everytime | 321 - 'updated' is set everytime |
322 @param extra(dict, None): same as for [XEP-0060.send_item] with additional keys: | 322 @param extra(dict, None): same as for [XEP-0060.send_item] with additional keys: |
323 - update(bool): if True, get previous item data to merge with current one | 323 - update(bool): if True, get previous item data to merge with current one |
324 if True, item_id must be set | 324 if True, item_id must be set |
325 - comments(bool): indicate if a new comment node must be created. | |
326 If True a new comment node will be create, and replace existing one if | |
327 there is already one. | |
328 If not set, comment node will be create if not ``item_id`` is specified, | |
329 and won't be modified otherwise. | |
325 other arguments are same as for [self._s.send_data_form_item] | 330 other arguments are same as for [self._s.send_data_form_item] |
326 @return (unicode): id of the created item | 331 @return (unicode): id of the created item |
327 """ | 332 """ |
328 if not node: | 333 if not node: |
329 node = self.namespace | 334 node = self.namespace |
330 | 335 |
331 if not item_id: | 336 if extra is None: |
337 extra = {} | |
338 | |
339 # FIXME: presence of a field where comments node can be added must be checked. | |
340 add_comments_node = extra.get("comments") | |
341 if add_comments_node or (add_comments_node is None and not item_id): | |
332 comments_service = await self._m.get_comments_service(client, service) | 342 comments_service = await self._m.get_comments_service(client, service) |
333 | 343 |
334 # we need to use uuid for comments node, because we don't know item id in | 344 # we need to use uuid for comments node, because we don't know item id in |
335 # advance (we don't want to set it ourselves to let the server choose, so we | 345 # advance (we don't want to set it ourselves to let the server choose, so we |
336 # can have a nicer id if serial ids is activated) | 346 # can have a nicer id if serial ids is activated) |