diff libervia/pages/tickets/view/page_meta.py @ 1302:04e7dd6b6f4d

pages (blog, tickets, merge-requests): updated code to handle new serialisation, following backend changes
author Goffi <goffi@goffi.org>
date Thu, 16 Jul 2020 09:08:47 +0200
parents f511f8fbbf8a
children
line wrap: on
line diff
--- a/libervia/pages/tickets/view/page_meta.py	Fri Jun 19 16:47:51 2020 +0200
+++ b/libervia/pages/tickets/view/page_meta.py	Thu Jul 16 09:08:47 2020 +0200
@@ -9,7 +9,7 @@
 from twisted.words.protocols.jabber import jid
 from sat.tools.common import template_xmlui
 from sat.tools.common import uri
-from sat.tools.common import data_objects
+from sat.tools.common import data_format
 from sat.core.log import getLogger
 
 log = getLogger(__name__)
@@ -31,8 +31,7 @@
     data["ticket_id"] = item_id
 
 
-@defer.inlineCallbacks
-def prepare_render(self, request):
+async def prepare_render(self, request):
     data = self.getRData(request)
     template_data = request.template_data
     session = self.host.getSessionData(request, session_iface.ISATSession)
@@ -46,7 +45,7 @@
     if profile is None:
         profile = C.SERVICE_PROFILE
 
-    tickets = yield self.host.bridgeCall(
+    tickets_raw = await self.host.bridgeCall(
         "ticketsGet",
         service.full() if service else "",
         node,
@@ -56,18 +55,19 @@
         {"labels_as_list": C.BOOL_TRUE},
         profile,
     )
-    ticket = [template_xmlui.create(self.host, x) for x in tickets[0]][0]
+    tickets, metadata = data_format.deserialise(tickets_raw, type_check=list)
+    ticket = [template_xmlui.create(self.host, x) for x in tickets][0]
     template_data["item"] = ticket
     comments_uri = ticket.widgets["comments_uri"].value
     if comments_uri:
         uri_data = uri.parseXMPPUri(comments_uri)
         template_data["comments_node"] = comments_node = uri_data["node"]
         template_data["comments_service"] = comments_service = uri_data["path"]
-        comments = yield self.host.bridgeCall(
+        comments = data_format.deserialise(await self.host.bridgeCall(
             "mbGet", comments_service, comments_node, C.NO_LIMIT, [], {}, profile
-        )
+        ))
 
-        template_data["comments"] = data_objects.BlogItems(comments)
+        template_data["comments"] = comments
         template_data["login_url"] = self.getPageRedirectURL(request)
 
     if session.connected:
@@ -77,7 +77,7 @@
         affiliation = None
         if not is_publisher:
             node = node or self.host.ns_map["tickets"]
-            affiliation = yield self.host.getAffiliation(request, service, node)
+            affiliation = await self.host.getAffiliation(request, service, node)
         if is_publisher or affiliation == "owner":
             template_data["url_ticket_edit"] = self.getURLByPath(
                 SubPage("tickets"),