diff libervia/pages/events/admin/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 d6bcb0cf92d2
line wrap: on
line diff
--- a/libervia/pages/events/admin/page_meta.py	Fri Jun 19 16:47:51 2020 +0200
+++ b/libervia/pages/events/admin/page_meta.py	Thu Jul 16 09:08:47 2020 +0200
@@ -5,6 +5,7 @@
 from twisted.internet import defer
 from twisted.words.protocols.jabber import jid
 from sat.tools.common.template import safe
+from sat.tools.common import data_format
 from sat.core.i18n import _
 from sat.core.log import getLogger
 import time
@@ -29,8 +30,7 @@
     )
 
 
-@defer.inlineCallbacks
-def prepare_render(self, request):
+async def prepare_render(self, request):
     data = self.getRData(request)
     template_data = request.template_data
 
@@ -40,7 +40,7 @@
     event_node = template_data["event_node"] = data["event_node"]
     event_id = template_data["event_id"] = data["event_id"]
     profile = self.getProfile(request)
-    event_timestamp, event_data = yield self.host.bridgeCall(
+    event_timestamp, event_data = await self.host.bridgeCall(
         "eventGet",
         event_service.userhost() if event_service else "",
         event_node,
@@ -62,7 +62,7 @@
             % html.escape(background_image, True)
         )
     template_data["event"] = event_data
-    invitees = yield self.host.bridgeCall(
+    invitees = await self.host.bridgeCall(
         "eventInviteesList",
         event_data["invitees_service"],
         event_data["invitees_node"],
@@ -93,11 +93,10 @@
     # we now need blog items, using blog common page
     # this will fill the "items" template data
     blog_page = self.getPageByName("blog_view")
-    yield blog_page.prepare_render(self, request)
+    await blog_page.prepare_render(self, request)
 
 
-@defer.inlineCallbacks
-def on_data_post(self, request):
+async def on_data_post(self, request):
     profile = self.getProfile(request)
     if not profile:
         log.error("got post data without profile")
@@ -121,10 +120,11 @@
             pass
         else:
             if comments:
-                data["allow_comments"] = C.BOOL_TRUE
+                data["allow_comments"] = True
 
         try:
-            yield self.host.bridgeCall("mbSend", service, node, data, profile)
+            await self.host.bridgeCall(
+                "mbSend", service, node, data_format.serialise(data), profile)
         except Exception as e:
             if "forbidden" in str(e):
                 self.pageError(request, C.HTTP_FORBIDDEN)
@@ -142,7 +142,7 @@
                     _("this is not a valid jid: {jid}").format(jid=invitee_jid_s)
                 )
                 continue
-            yield self.host.bridgeCall(
+            await self.host.bridgeCall(
                 "eventInvite", invitee_jid.userhost(), service, node, event_id, profile
             )
         for email_addr in emails.split():
@@ -153,7 +153,7 @@
                     )
                 )
                 continue
-            yield self.host.bridgeCall(
+            await self.host.bridgeCall(
                 "eventInviteByEmail",
                 service,
                 node,