Commit 8b120874 authored by Bryton Lacquement's avatar Bryton Lacquement 🚪

Document/{File,PDFDocument}: drop the precondition to edit a file

'precondition' was an attribute from Products.CMFDefault. As we dropped
the latter, and the attribute has never been used in ERP5, we can delete
it.
parent ed4eb2d4
...@@ -346,9 +346,9 @@ class PDFDocument(Image): ...@@ -346,9 +346,9 @@ class PDFDocument(Image):
self._content_information = result self._content_information = result
return result.copy() return result.copy()
def _setFile(self, data, precondition=None): def _setFile(self, data):
try: try:
del self._content_information del self._content_information
except (AttributeError, KeyError): except (AttributeError, KeyError):
pass pass
Image._setFile(self, data, precondition=precondition) Image._setFile(self, data)
...@@ -101,7 +101,6 @@ class File(Document, OFS_File): ...@@ -101,7 +101,6 @@ class File(Document, OFS_File):
""" """
if 'file' in kw: if 'file' in kw:
file_object = kw.pop('file') file_object = kw.pop('file')
precondition = kw.get('precondition')
filename = getattr(file_object, 'filename', None) filename = getattr(file_object, 'filename', None)
# if file field is empty(no file is uploaded), # if file field is empty(no file is uploaded),
# filename is empty string. # filename is empty string.
...@@ -119,7 +118,7 @@ class File(Document, OFS_File): ...@@ -119,7 +118,7 @@ class File(Document, OFS_File):
file_object.seek(0, 2) file_object.seek(0, 2)
if file_object.tell(): if file_object.tell():
file_object.seek(0) file_object.seek(0)
self._setFile(file_object, precondition=precondition) self._setFile(file_object)
Base._edit(self, **kw) Base._edit(self, **kw)
security.declareProtected( Permissions.ModifyPortalContent, 'edit' ) security.declareProtected( Permissions.ModifyPortalContent, 'edit' )
...@@ -145,22 +144,20 @@ class File(Document, OFS_File): ...@@ -145,22 +144,20 @@ class File(Document, OFS_File):
""" """
return None return None
def _setFile(self, data, precondition=None): def _setFile(self, data):
if data is not None and \ if data is None:
str(data.read()) == (self.hasData() and str(self.getData())): return
if str(data.read()) == (self.hasData() and str(self.getData())):
# Same data as previous, no need to change its content # Same data as previous, no need to change its content
return return
# from Products.CMFDefault.File if data.tell():
if precondition: self.precondition = precondition
elif self.precondition: del self.precondition
if data is not None and data.tell():
data.seek(0) data.seek(0)
self.manage_upload(data) self.manage_upload(data)
security.declareProtected(Permissions.ModifyPortalContent,'setFile') security.declareProtected(Permissions.ModifyPortalContent,'setFile')
def setFile(self, data, precondition=None): def setFile(self, data):
self._setFile(data, precondition=precondition) self._setFile(data)
self.reindexObject() self.reindexObject()
security.declareProtected(Permissions.AccessContentsInformation, 'hasFile') security.declareProtected(Permissions.AccessContentsInformation, 'hasFile')
......
...@@ -69,7 +69,6 @@ class TestFormPrintoutAsODG(TestFormPrintoutMixin): ...@@ -69,7 +69,6 @@ class TestFormPrintoutAsODG(TestFormPrintoutMixin):
addStyleSheet = custom.manage_addProduct['OFSP'].manage_addFile addStyleSheet = custom.manage_addProduct['OFSP'].manage_addFile
if custom._getOb('Foo_getODGStyleSheet', None) is None: if custom._getOb('Foo_getODGStyleSheet', None) is None:
addStyleSheet(id='Foo_getODGStyleSheet', file=foo_file, title='', addStyleSheet(id='Foo_getODGStyleSheet', file=foo_file, title='',
precondition='',
content_type='application/vnd.oasis.opendocument.graphics') content_type='application/vnd.oasis.opendocument.graphics')
erp5OOo = custom.manage_addProduct['ERP5OOo'] erp5OOo = custom.manage_addProduct['ERP5OOo']
......
...@@ -84,23 +84,22 @@ class TestFormPrintoutAsODT(TestFormPrintoutMixin): ...@@ -84,23 +84,22 @@ class TestFormPrintoutAsODT(TestFormPrintoutMixin):
addStyleSheet = custom.manage_addProduct['OFSP'].manage_addFile addStyleSheet = custom.manage_addProduct['OFSP'].manage_addFile
if custom._getOb('Foo_getODTStyleSheet', None) is None: if custom._getOb('Foo_getODTStyleSheet', None) is None:
addStyleSheet(id='Foo_getODTStyleSheet', file=foo_file, title='', addStyleSheet(id='Foo_getODTStyleSheet', file=foo_file, title='',
precondition='', content_type = 'application/vnd.oasis.opendocument.text') content_type = 'application/vnd.oasis.opendocument.text')
if custom._getOb('Foo2_getODTStyleSheet', None) is None: if custom._getOb('Foo2_getODTStyleSheet', None) is None:
addStyleSheet(id='Foo2_getODTStyleSheet', file=foo2_file, title='', addStyleSheet(id='Foo2_getODTStyleSheet', file=foo2_file, title='',
precondition='', content_type = 'application/vnd.oasis.opendocument.text') content_type = 'application/vnd.oasis.opendocument.text')
if custom._getOb('Foo3_getODTStyleSheet', None) is None: if custom._getOb('Foo3_getODTStyleSheet', None) is None:
addStyleSheet(id='Foo3_getODTStyleSheet', file=foo3_file, title='', addStyleSheet(id='Foo3_getODTStyleSheet', file=foo3_file, title='',
precondition='', content_type = 'application/vnd.oasis.opendocument.text') content_type = 'application/vnd.oasis.opendocument.text')
if custom._getOb('Foo4_getODTStyleSheet', None) is None: if custom._getOb('Foo4_getODTStyleSheet', None) is None:
addStyleSheet(id='Foo4_getODTStyleSheet', file=foo4_file, title='', addStyleSheet(id='Foo4_getODTStyleSheet', file=foo4_file, title='',
precondition='', content_type = 'application/vnd.oasis.opendocument.text') content_type = 'application/vnd.oasis.opendocument.text')
if custom._getOb('Foo5_getODTStyleSheet', None) is None: if custom._getOb('Foo5_getODTStyleSheet', None) is None:
addStyleSheet(id='Foo5_getODTStyleSheet', file=foo5_file, title='', addStyleSheet(id='Foo5_getODTStyleSheet', file=foo5_file, title='',
precondition='', content_type = 'application/vnd.oasis.opendocument.text') content_type = 'application/vnd.oasis.opendocument.text')
if custom._getOb('Foo_getVariableODTStyleSheet', None) is None: if custom._getOb('Foo_getVariableODTStyleSheet', None) is None:
addStyleSheet(id='Foo_getVariableODTStyleSheet', addStyleSheet(id='Foo_getVariableODTStyleSheet',
file=variable_file_object, title='', file=variable_file_object, title='',
precondition='',
content_type='application/vnd.oasis.opendocument.text') content_type='application/vnd.oasis.opendocument.text')
erp5OOo = custom.manage_addProduct['ERP5OOo'] erp5OOo = custom.manage_addProduct['ERP5OOo']
......
...@@ -67,7 +67,7 @@ class TestOoodResponse(ERP5TypeTestCase): ...@@ -67,7 +67,7 @@ class TestOoodResponse(ERP5TypeTestCase):
custom = portal_skins.custom custom = portal_skins.custom
addStyleSheet = custom.manage_addProduct['OFSP'].manage_addFile addStyleSheet = custom.manage_addProduct['OFSP'].manage_addFile
addStyleSheet(id='Base_getODTStyleSheet', file=import_file, title='', addStyleSheet(id='Base_getODTStyleSheet', file=import_file, title='',
precondition='', content_type='application/vnd.oasis.opendocument.text') content_type='application/vnd.oasis.opendocument.text')
addOOoTemplate = custom.manage_addProduct['ERP5OOo'].addOOoTemplate addOOoTemplate = custom.manage_addProduct['ERP5OOo'].addOOoTemplate
addOOoTemplate(id='ERP5Site_viewNothingAsOdt', title='') addOOoTemplate(id='ERP5Site_viewNothingAsOdt', title='')
portal_skins.changeSkin(skinname=None) portal_skins.changeSkin(skinname=None)
......
...@@ -76,10 +76,10 @@ class TestOooDynamicStyle(ERP5TypeTestCase): ...@@ -76,10 +76,10 @@ class TestOooDynamicStyle(ERP5TypeTestCase):
addStyleSheet = self.getPortal().manage_addProduct['OFSP'].manage_addFile addStyleSheet = self.getPortal().manage_addProduct['OFSP'].manage_addFile
if getattr(self.getPortal(), 'Test_getODTStyleSheet_en', None) is None: if getattr(self.getPortal(), 'Test_getODTStyleSheet_en', None) is None:
addStyleSheet(id='Test_getODTStyleSheet_en', file=en_file, title='', addStyleSheet(id='Test_getODTStyleSheet_en', file=en_file, title='',
precondition='', content_type=self.content_type_writer) content_type=self.content_type_writer)
if getattr(self.getPortal(), 'Test_getODTStyleSheet_ja', None) is None: if getattr(self.getPortal(), 'Test_getODTStyleSheet_ja', None) is None:
addStyleSheet(id='Test_getODTStyleSheet_ja', file=ja_file, title='', addStyleSheet(id='Test_getODTStyleSheet_ja', file=ja_file, title='',
precondition='', content_type=self.content_type_writer) content_type=self.content_type_writer)
if getattr(self.getPortal(), 'Base_getODTStyleSheetByLanguage', None) is None: if getattr(self.getPortal(), 'Base_getODTStyleSheetByLanguage', None) is None:
script_body = """ script_body = """
current_language = context.Localizer.get_selected_language() current_language = context.Localizer.get_selected_language()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment