Mercurial > libervia-web
comparison libervia/pages/lists/view_item/page_meta.py @ 1468:e85ef5f3515e
pages (lists/view_item): add current list to breadcrumbs
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 01 Oct 2021 12:12:30 +0200 |
parents | 8ac062d2ff8b |
children | 837ae0c4b858 |
comparison
equal
deleted
inserted
replaced
1467:d6062cccd4c0 | 1468:e85ef5f3515e |
---|---|
1 #!/usr/bin/env python3 | 1 #!/usr/bin/env python3 |
2 | 2 |
3 from twisted.words.protocols.jabber import jid | 3 from twisted.words.protocols.jabber import jid |
4 from sat.core.i18n import _ | 4 from sat.core.i18n import _, D_ |
5 from sat.tools.common import template_xmlui | 5 from sat.tools.common import template_xmlui |
6 from sat.tools.common import uri | 6 from sat.tools.common import uri |
7 from sat.tools.common import data_format | 7 from sat.tools.common import data_format |
8 from sat.core.log import getLogger | 8 from sat.core.log import getLogger |
9 from sat_frontends.bridge.bridge_frontend import BridgeException | 9 from sat_frontends.bridge.bridge_frontend import BridgeException |
23 self.getPathArgs(request, ["service", "node", "item_id"], service="jid", node="@") | 23 self.getPathArgs(request, ["service", "node", "item_id"], service="jid", node="@") |
24 data = self.getRData(request) | 24 data = self.getRData(request) |
25 if data["item_id"] is None: | 25 if data["item_id"] is None: |
26 log.warning(_("no list item id specified")) | 26 log.warning(_("no list item id specified")) |
27 self.pageError(request, C.HTTP_BAD_REQUEST) | 27 self.pageError(request, C.HTTP_BAD_REQUEST) |
28 | |
29 | |
30 def add_breadcrumb(self, request, breadcrumbs): | |
31 data = self.getRData(request) | |
32 list_url = self.getPageByName("lists").getURL(data["service"].full(), | |
33 data.get("node") or "@") | |
34 breadcrumbs.append({ | |
35 "label": D_("List"), | |
36 "url": list_url | |
37 }) | |
38 breadcrumbs.append({ | |
39 "label": D_("item"), | |
40 }) | |
41 | |
28 | 42 |
29 async def prepare_render(self, request): | 43 async def prepare_render(self, request): |
30 data = self.getRData(request) | 44 data = self.getRData(request) |
31 template_data = request.template_data | 45 template_data = request.template_data |
32 session = self.host.getSessionData(request, session_iface.ISATSession) | 46 session = self.host.getSessionData(request, session_iface.ISATSession) |
50 [item_id], | 64 [item_id], |
51 "", | 65 "", |
52 {"labels_as_list": C.BOOL_TRUE}, | 66 {"labels_as_list": C.BOOL_TRUE}, |
53 profile, | 67 profile, |
54 ) | 68 ) |
55 list_items, metadata = data_format.deserialise(list_raw, type_check=list) | 69 list_items, __ = data_format.deserialise(list_raw, type_check=list) |
56 list_item = [template_xmlui.create(self.host, x) for x in list_items][0] | 70 list_item = [template_xmlui.create(self.host, x) for x in list_items][0] |
57 template_data["item"] = list_item | 71 template_data["item"] = list_item |
58 try: | 72 try: |
59 comments_uri = list_item.widgets["comments_uri"].value | 73 comments_uri = list_item.widgets["comments_uri"].value |
60 except KeyError: | 74 except KeyError: |