X-Git-Url: https://svn.cri.ensmp.fr/git/Plinn.git/blobdiff_plain/3e0a2c257d49fb162da9c70d2f70194036235166..47c592d60c4673c0dd7ad36b579a7aa47a87529c:/skins/custom_content/document_edit_form.py?ds=inline

diff --git a/skins/custom_content/document_edit_form.py b/skins/custom_content/document_edit_form.py
index 82602ec..8dffe34 100644
--- a/skins/custom_content/document_edit_form.py
+++ b/skins/custom_content/document_edit_form.py
@@ -1,25 +1,28 @@
 ##parameters=change='', change_and_view='', ajax=''
-##
+from Products.CMFCore.utils import getToolByName
+atool = getToolByName(context, 'portal_attachment')
+attachments = atool.getAttachmentsFor(context)
+
 form = context.REQUEST.form
 text = form.get('text')
 if text and same_type(text, []) :
-	# when javascript is disabled,
-	# there's a hidden textarea from epoz
-	# and an other from <noscript> tag
-	form.update({'text' : text[1]}) 
+    # when javascript is disabled,
+    # there's a hidden textarea from epoz
+    # and an other from <noscript> tag
+    form.update({'text' : text[1]}) 
 
 if change and \
-		context.validateTextFile(**form) and \
-		context.validateHTML(**form) and \
-		context.document_edit_control(**form) and \
-		context.setRedirect(context, 'object/edit', **{'ajax':ajax}):
-	return
+        context.validateTextFile(**form) and \
+        context.validateHTML(**form) and \
+        context.document_edit_control(text=form.get('text'), text_format='html') and \
+        context.setRedirect(context, 'object/edit', **{'ajax':ajax}):
+    return
 elif change_and_view and \
-		context.validateTextFile(**form) and \
-		context.validateHTML(**form) and \
-		context.document_edit_control(**form) and \
-		context.setRedirect(context, 'object/view', **{'ajax':ajax}):
-	return
+        context.validateTextFile(**form) and \
+        context.validateHTML(**form) and \
+        context.document_edit_control(text=form.get('text'), text_format='html') :
+    attachments.removeUnusedAttachments(context.EditableBody())
+    return context.setRedirect(context, 'object/view', **{'ajax':ajax})
 
 
 options = {}
@@ -29,6 +32,6 @@ target = context.getActionInfo('object/edit')['url']
 buttons.append( {'name': 'change', 'value': 'Change'} )
 buttons.append( {'name': 'change_and_view', 'value': 'Change and View'} )
 options['form'] = { 'action': target,
-					'listButtonInfos': tuple(buttons) }
+                    'listButtonInfos': tuple(buttons) }
 
 return context.document_edit_template(**options)