Commit 3e9ef826 authored by Tristan Cavelier's avatar Tristan Cavelier

erp5_officejs_support_request_ui: remove code duplication

parent 434cbdb3
...@@ -5,7 +5,7 @@ post = context.PostModule_createHTMLPostFromText( ...@@ -5,7 +5,7 @@ post = context.PostModule_createHTMLPostFromText(
data=data, data=data,
) )
if file != "undefined": # XXX "undefined" ? should also be fixed in javascript side if file not in ("undefined", None): # XXX "undefined" ? should also be fixed in javascript side
document_kw = {'batch_mode': True, document_kw = {'batch_mode': True,
'redirect_to_document': False, 'redirect_to_document': False,
'file': file} 'file': file}
......
...@@ -36,32 +36,14 @@ support_request.edit( ...@@ -36,32 +36,14 @@ support_request.edit(
support_request.submit() support_request.submit()
support_request.immediateReindexObject() support_request.immediateReindexObject()
# create an HTML Post if description is not None or file is not None:
if description or file is not None: portal.post_module.PostModule_createHTMLPostForSupportRequest(
post_module = portal.post_module follow_up=support_request.getRelativeUrl(), # XXX give support_request as follow_up_value
post = post_module.newContent(portal_type='HTML Post') predecessor=None,
data="" if description is None else description,
post.edit( file=file,
start_date=now,
follow_up_value=support_request,
text_content="<p>" + description.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;").replace(" ", " &nbsp;").replace("\n", "<br/>") + "</p>",
) )
# handle attachments
if getattr(file, 'filename', '') != '':
document_kw = {'batch_mode': True,
'redirect_to_document': False,
'file': file}
document = context.Base_contribute(**document_kw)
# set relation between post and document
post.setSuccessorValueList([document])
# depending on security model this should be changed accordingly
document.publish()
post.publish()
post.immediateReindexObject()
return support_request.Base_redirect('officejs_support_request_view', return support_request.Base_redirect('officejs_support_request_view',
keep_items={ keep_items={
'portal_status_message': portal.Base_translateString( 'portal_status_message': portal.Base_translateString(
......
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