Skip to content

Commit 3f45ce0

Browse files
committed
available templates change
1 parent 64f32f3 commit 3f45ce0

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/cs_dynamicpages/views/dynamic_view.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
from zope.interface import alsoProvides
99
from zope.interface import implementer
1010
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
1114

1215

1316
class IDynamicView(Interface):
@@ -76,8 +79,26 @@ def normalize_title(self, title):
7679
)
7780

7881
def available_templates(self):
82+
portal_types = api.portal.get_tool("portal_types")
7983
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
81102

82103
def self_in_templates(self):
83104
if "rows" in self.context:

0 commit comments

Comments
 (0)