diff --git a/product/ERP5/Document/Document.py b/product/ERP5/Document/Document.py index a475bd3124217a1c98c78961fccdea1a04a7be0f..fbd4674680b20fa60b7c6a137918476d5bfcbdc8 100644 --- a/product/ERP5/Document/Document.py +++ b/product/ERP5/Document/Document.py @@ -1104,7 +1104,7 @@ class Document(PermanentURLMixIn, XMLObject, UrlMixIn, CachedConvertableMixin, S return method() # Conversion methods - security.declareProtected(Permissions.ModifyPortalContent, 'convert') + security.declareProtected(Permissions.AccessContentsInformation, 'convert') def convert(self, format, **kw): """ Main content conversion function, returns result which should @@ -1278,7 +1278,7 @@ class Document(PermanentURLMixIn, XMLObject, UrlMixIn, CachedConvertableMixin, S """ if getattr(self, 'hasData', None) is not None and not self.hasData(): # Empty document cannot be converted - return #'Document is empty' + return try: message = self._convertToBaseFormat() # Call implemetation method self.clearConversionCache() # Conversion cache is now invalid diff --git a/product/ERP5/Document/Image.py b/product/ERP5/Document/Image.py index de57b1f8b799628d5f1cfc3467e81d2c69428312..443232f095a05ffee00bd0df9706016deb01a9f6 100644 --- a/product/ERP5/Document/Image.py +++ b/product/ERP5/Document/Image.py @@ -325,7 +325,7 @@ class Image(File, OFSImage): return mime_type, result # Conversion API - security.declareProtected(Permissions.ModifyPortalContent, 'convert') + security.declareProtected(Permissions.AccessContentsInformation, 'convert') def convert(self, format, display=None, quality=75, resolution=None, frame=None, **kw): """ Implementation of conversion for Image files diff --git a/product/ERP5/Document/PDFDocument.py b/product/ERP5/Document/PDFDocument.py index 65c72ed0016dae89f289b7bdaacc403f364cdfaa..d8b2b288ed60a43b7af473f5fc09b1046261df2e 100644 --- a/product/ERP5/Document/PDFDocument.py +++ b/product/ERP5/Document/PDFDocument.py @@ -101,7 +101,7 @@ class PDFDocument(Image, CachedConvertableMixin): resolution=resolution, frame=frame) # Conversion API - security.declareProtected(Permissions.ModifyPortalContent, 'convert') + security.declareProtected(Permissions.AccessContentsInformation, 'convert') def convert(self, format, **kw): """ Implementation of conversion for PDF files diff --git a/product/ERP5/Document/TextDocument.py b/product/ERP5/Document/TextDocument.py index c5b29218494eaf92c5b307f510a2a364da98a0ad..cc903291eeb939b0d2a998e05aa7d8f2566f7c44 100644 --- a/product/ERP5/Document/TextDocument.py +++ b/product/ERP5/Document/TextDocument.py @@ -195,7 +195,7 @@ class TextDocument(Document, TextContent): substitution_method_parameter_dict = {} return self._substituteTextContent(subject, **substitution_method_parameter_dict) - security.declareProtected(Permissions.View, 'convert') + security.declareProtected(Permissions.AccessContentsInformation, 'convert') def convert(self, format, substitution_method_parameter_dict=None, **kw): """ Convert text using portal_transforms or oood diff --git a/product/ERP5/interfaces/convertable.py b/product/ERP5/interfaces/convertable.py index ef8583c40c1c9915d8d432a7e35317ff34ec7869..fd7470d2bab4f0ccab0265f7518a8b0677ae0e20 100644 --- a/product/ERP5/interfaces/convertable.py +++ b/product/ERP5/interfaces/convertable.py @@ -45,6 +45,10 @@ class IConvertable(Interface): taking into account optional parameters. This method returns a tuple of two values: a mime type string and the converted data. + + This methods raises a ConversionError if the target format + is not allowed, or an Unauthorized error if the target format + is not permitted. format -- the target conversion format specified either as an extension (ex. 'png') or as a mime type @@ -104,4 +108,4 @@ class IConvertable(Interface): Returns the list of acceptable formats for conversion where format is an extension (ex. 'png') which can be passed to IConvertable.convert or to IDownloadable.index_html - """ \ No newline at end of file + """ diff --git a/product/ERP5OOo/Document/OOoDocument.py b/product/ERP5OOo/Document/OOoDocument.py index 0dec8f00f7b378ee8c193fea747aa64e9055e032..c5b36ef338fccaa9078209b13275b32e83f84c34 100644 --- a/product/ERP5OOo/Document/OOoDocument.py +++ b/product/ERP5OOo/Document/OOoDocument.py @@ -353,7 +353,7 @@ class OOoDocument(PermanentURLMixIn, File, CachedConvertableMixin): return response_dict['mime'], Pdata(dec(response_dict['data'])) # Conversion API - security.declareProtected(Permissions.View, 'convert') + security.declareProtected(Permissions.AccessContentsInformation, 'convert') def convert(self, format, display=None, **kw): """Convert the document to the given format.