|
8 | 8 | from zope.interface import alsoProvides |
9 | 9 | from zope.interface import implementer |
10 | 10 | from zope.interface import Interface |
| 11 | +from Acquisition import aq_parent |
| 12 | +from zope.i18n import translate |
| 13 | +from plone.app.uuid.utils import uuidToObject |
11 | 14 |
|
12 | 15 |
|
13 | 16 | class IDynamicView(Interface): |
@@ -76,8 +79,26 @@ def normalize_title(self, title): |
76 | 79 | ) |
77 | 80 |
|
78 | 81 | def available_templates(self): |
| 82 | + portal_types = api.portal.get_tool("portal_types") |
79 | 83 | manager = Manager(self.context) |
80 | | - return manager.get_templates() |
| 84 | + templates = [] |
| 85 | + for template in manager.get_templates(): |
| 86 | + obj = uuidToObject(template.get("uid")) |
| 87 | + if obj: |
| 88 | + parent = aq_parent(obj) |
| 89 | + template.update({ |
| 90 | + "Title": parent.Title(), |
| 91 | + "Description": parent.Description(), |
| 92 | + "absolute_url": parent.absolute_url(), |
| 93 | + "portal_type": parent.portal_type, |
| 94 | + "translated_portal_type": translate( |
| 95 | + portal_types.get(parent.portal_type).title, |
| 96 | + domain=portal_types.get(parent.portal_type).i18n_domain, |
| 97 | + context=self.request, |
| 98 | + ), |
| 99 | + }) |
| 100 | + templates.append(template) |
| 101 | + return templates |
81 | 102 |
|
82 | 103 | def self_in_templates(self): |
83 | 104 | if "rows" in self.context: |
|
0 commit comments