diff --git a/product/ERP5Form/PreferenceTool.py b/product/ERP5Form/PreferenceTool.py index 9612cd0945c083d2932c322265ffd64340457414..d48ee5405209792c509b1f88b81be960f3b7ada8 100755 --- a/product/ERP5Form/PreferenceTool.py +++ b/product/ERP5Form/PreferenceTool.py @@ -183,18 +183,18 @@ class PreferenceTool(BaseTool): if len(enabled_prefs) > 0 : return enabled_prefs[0] - security.declareProtected(Permissions.View, 'getDocumentTemplate') - def getDocumentTemplate(self, folder) : + security.declareProtected(Permissions.View, 'getDocumentTemplateList') + def getDocumentTemplateList(self, folder) : """ returns all document templates that are in acceptable Preferences based on different criteria such as folder, portal_type, etc. XXX This spec still needs to be refined before implementation """ acceptable_templates = [] + allowed_content_types = map(lambda pti: pti.id, folder.allowedContentTypes()) for pref in self._getSortedPreferenceList() : for doc in pref.objectValues() : - if hasattr(doc, 'getTemplateDestinationUidList') and \ - folder.getUid() in doc.getTemplateDestinationUidList() : + if doc.getPortalTypes() in allowed_content_types: acceptable_templates.append (doc) return acceptable_templates diff --git a/product/ERP5Type/Document/Folder.py b/product/ERP5Type/Document/Folder.py index 3dc961ec1e772fdde829040b1435b42e770b3640..a4665dc14a9318faad5cb17a9d9deaa1773492c2 100755 --- a/product/ERP5Type/Document/Folder.py +++ b/product/ERP5Type/Document/Folder.py @@ -727,5 +727,13 @@ be a problem).""" security.declareProtected( Permissions.AccessContentsInformation, 'manage_copyObjects' ) # XXX Why this one doesn't work in CopySupport ? security.declareProtected( Permissions.AddPortalContent, 'manage_pasteObjects' ) # XXX Why this one doesn't work in CopySupport ? + security.declareProtected(Permissions.View, 'getDocumentTemplateList') + def getDocumentTemplateList(self) : + """ + Returns the list of allowed templates for this folder + by calling the preference tool + """ + return self.getPortalObject().portal_preferences_getDocumentTemplateList(self) + # Overwrite Zope setTitle() Folder.setTitle = Base.setTitle