Mercurial > libervia-web
diff libervia/pages/forums/topics/page_meta.py @ 1427:eaf36fffcbdb
pages (forums): better breadcrumbs
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 01 May 2021 19:05:16 +0200 |
parents | bcd6ad99b2b0 |
children | fa6fe9511aca |
line wrap: on
line diff
--- a/libervia/pages/forums/topics/page_meta.py Sat May 01 19:05:16 2021 +0200 +++ b/libervia/pages/forums/topics/page_meta.py Sat May 01 19:05:16 2021 +0200 @@ -2,8 +2,7 @@ from libervia.server.constants import Const as C -from twisted.internet import defer -from sat.core.i18n import _ +from sat.core.i18n import _, D_ from sat.core.log import getLogger from sat.tools.common import uri as xmpp_uri from sat.tools.common import data_format @@ -12,6 +11,7 @@ log = getLogger(__name__) name = "forum_topics" +label = D_("Forum Topics") access = C.PAGES_ACCESS_PUBLIC template = "forum/view_topics.html" @@ -20,14 +20,21 @@ self.getPathArgs(request, ["service", "node"], 2, service="jid") -@defer.inlineCallbacks -def prepare_render(self, request): +def add_breadcrumb(self, request, breadcrumbs): + data = self.getRData(request) + breadcrumbs.append({ + "label": label, + "url": self.getURL(data["service"].full(), data["node"]) + }) + + +async def prepare_render(self, request): profile = self.getProfile(request) or C.SERVICE_PROFILE data = self.getRData(request) service, node = data["service"], data["node"] request.template_data.update({"service": service, "node": node}) template_data = request.template_data - topics, metadata = yield self.host.bridgeCall( + topics, metadata = await self.host.bridgeCall( "forumTopicsGet", service.full(), node, {}, profile ) identities = self.host.getSessionData( @@ -40,7 +47,7 @@ parsed_uri["path"], parsed_uri["node"] ) if author not in identities: - id_raw = yield self.host.bridgeCall( + id_raw = await self.host.bridgeCall( "identityGet", author, [], True, profile ) identities[topic["author"]] = data_format.deserialise(id_raw) @@ -49,8 +56,7 @@ template_data["url_topic_new"] = self.getSubPageURL(request, "forum_topic_new") -@defer.inlineCallbacks -def on_data_post(self, request): +async def on_data_post(self, request): profile = self.getProfile(request) if profile is None: self.pageError(request, C.HTTP_FORBIDDEN) @@ -64,7 +70,7 @@ self.pageError(request, C.HTTP_BAD_REQUEST) topic_data = {"title": title, "content": body} try: - yield self.host.bridgeCall( + await self.host.bridgeCall( "forumTopicCreate", service, node, topic_data, profile ) except Exception as e: