Mercurial > libervia-web
diff libervia/pages/merge-requests/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 | e3e303a30a74 |
line wrap: on
line diff
--- a/libervia/pages/merge-requests/view/page_meta.py Fri Jun 19 16:47:51 2020 +0200 +++ b/libervia/pages/merge-requests/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 name = "merge-requests_view" @@ -29,8 +29,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) @@ -44,29 +43,32 @@ if profile is None: profile = C.SERVICE_PROFILE - tickets, metadata, parsed_tickets = yield self.host.bridgeCall( - "mergeRequestsGet", - service.full() if service else "", - node, - C.NO_LIMIT, - [ticket_id], - "", - {"parse": C.BOOL_TRUE, "labels_as_list": C.BOOL_TRUE}, - profile, + merge_requests = data_format.deserialise( + await self.host.bridgeCall( + "mergeRequestsGet", + service.full() if service else "", + node, + C.NO_LIMIT, + [ticket_id], + "", + {"parse": C.BOOL_TRUE, "labels_as_list": C.BOOL_TRUE}, + profile, + ) ) - ticket = template_xmlui.create(self.host, tickets[0], ignore=["request_data", "type"]) + ticket = template_xmlui.create( + self.host, merge_requests['items'][0], ignore=["request_data", "type"] + ) template_data["item"] = ticket - template_data["patches"] = parsed_tickets[0] + template_data["patches"] = merge_requests['items_patches'][0] 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( + template_data["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["login_url"] = self.getPageRedirectURL(request) if session.connected: @@ -76,7 +78,7 @@ affiliation = None if not is_publisher: node = node or self.host.ns_map["merge_requests"] - 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("merge-requests"), @@ -87,11 +89,10 @@ ) -@defer.inlineCallbacks -def on_data_post(self, request): +async def on_data_post(self, request): type_ = self.getPostedData(request, "type") if type_ == "comment": blog_page = self.getPageByName("blog_view") - yield blog_page.on_data_post(self, request) + await blog_page.on_data_post(self, request) else: log.warning(_("Unhandled data type: {}").format(type_))