comparison libervia/frontends/quick_frontend/quick_blog.py @ 4270:0d7bb4df2343

Reformatted code base using black.
author Goffi <goffi@goffi.org>
date Wed, 19 Jun 2024 18:44:57 +0200
parents 26b7ed2817da
children
comparison
equal deleted inserted replaced
4269:64a85ce8be70 4270:0d7bb4df2343
51 """ 51 """
52 self.id = data["id"] 52 self.id = data["id"]
53 self.title = data.get("title") 53 self.title = data.get("title")
54 self.title_rich = None 54 self.title_rich = None
55 self.title_xhtml = data.get("title_xhtml") 55 self.title_xhtml = data.get("title_xhtml")
56 self.tags = data.get('tags', []) 56 self.tags = data.get("tags", [])
57 self.content = data.get("content") 57 self.content = data.get("content")
58 self.content_rich = None 58 self.content_rich = None
59 self.content_xhtml = data.get("content_xhtml") 59 self.content_xhtml = data.get("content_xhtml")
60 self.author = data["author"] 60 self.author = data["author"]
61 try: 61 try:
143 """ 143 """
144 items, metadata = items_tuple 144 items, metadata = items_tuple
145 for item, comments in items: 145 for item, comments in items:
146 self.add_entry(item, comments, service=service, node=node, with_update=False) 146 self.add_entry(item, comments, service=service, node=node, with_update=False)
147 147
148 def add_entry(self, item=None, comments=None, service=None, node=None, 148 def add_entry(
149 with_update=True, editable=False, edit_entry=False): 149 self,
150 item=None,
151 comments=None,
152 service=None,
153 node=None,
154 with_update=True,
155 editable=False,
156 edit_entry=False,
157 ):
150 """Add a microblog entry 158 """Add a microblog entry
151 159
152 @param editable (bool): True if the entry can be modified 160 @param editable (bool): True if the entry can be modified
153 @param item (dict, None): blog item data, or None for an empty entry 161 @param item (dict, None): blog item data, or None for an empty entry
154 @param comments (list, None): list of comments data if available 162 @param comments (list, None): list of comments data if available
273 name = "{}{}".format(prefix, suffix) 281 name = "{}{}".format(prefix, suffix)
274 value = getattr(self.item, name) 282 value = getattr(self.item, name)
275 if value is not None: 283 if value is not None:
276 mb_data[name] = value 284 mb_data[name] = value
277 285
278 mb_data['tags'] = self.item.tags 286 mb_data["tags"] = self.item.tags
279 287
280 if self.blog.new_message_target not in (C.PUBLIC, C.GROUP): 288 if self.blog.new_message_target not in (C.PUBLIC, C.GROUP):
281 raise NotImplementedError 289 raise NotImplementedError
282 290
283 if self.level == 0: 291 if self.level == 0:
284 mb_data["allow_comments"] = True 292 mb_data["allow_comments"] = True
285 293
286 if self.blog.new_message_target == C.GROUP: 294 if self.blog.new_message_target == C.GROUP:
287 mb_data['groups'] = list(self.blog.targets) 295 mb_data["groups"] = list(self.blog.targets)
288 296
289 self.blog.host.bridge.mb_send( 297 self.blog.host.bridge.mb_send(
290 str(self.service or ""), 298 str(self.service or ""),
291 self.node or "", 299 self.node or "",
292 data_format.serialise(mb_data), 300 data_format.serialise(mb_data),
389 for result in results: 397 for result in results:
390 service, node, failure, items_data, metadata = result 398 service, node, failure, items_data, metadata = result
391 for item_data in items_data: 399 for item_data in items_data:
392 item_data[0] = data_format.deserialise(item_data[0]) 400 item_data[0] = data_format.deserialise(item_data[0])
393 for item_metadata in item_data[1]: 401 for item_metadata in item_data[1]:
394 item_metadata[3] = [data_format.deserialise(i) for i in item_metadata[3]] 402 item_metadata[3] = [
403 data_format.deserialise(i) for i in item_metadata[3]
404 ]
395 if not failure: 405 if not failure:
396 self._add_mb_items_with_comments((items_data, metadata), 406 self._add_mb_items_with_comments(
397 service=jid.JID(service)) 407 (items_data, metadata), service=jid.JID(service)
408 )
398 409
399 self.update() 410 self.update()
400 if remaining: 411 if remaining:
401 self._get_results(rt_session) 412 self._get_results(rt_session)
402 413