Commit d1eb52cd authored by Tristan Cavelier's avatar Tristan Cavelier

erp5_post: change create HTML post API

keep backward compatibility with erp5_officejs_support_request_ui
parent abc20a0e
follow_up_object, = context.getPortalObject().portal_catalog(relative_url=follow_up, limit=1)
follow_up_object.edit() # update modification date
result = context.PostModule_createHTMLPostFromText(
follow_up,
predecessor,
data,
file,
post = context.PostModule_createHTMLPostFromText(
follow_up=follow_up,
data=data,
)
return result
if file != "undefined": # XXX "undefined" ? should also be fixed in javascript side
document_kw = {'batch_mode': True,
'redirect_to_document': False,
'file': file}
document = context.Base_contribute(**document_kw)
# set relation between post and document
# XXX successor is used as a way to put a relation between the attachment and the post,
# the actual way should be to use a proper container like an Event that will have
# one or several posts and one or several attachments.
post.setSuccessorValueList([document])
# XXX depending on security model this should be changed accordingly
document.publish()
portal = context.getPortalObject()
now = DateTime()
# create an HTML Post
post_module = portal.post_module
......@@ -14,27 +12,20 @@ if object_list:
else:
raise LookupError("Target follow up object not found")
post.edit(
start_date=now,
follow_up_value=follow_up_object,
predecessor_value = predecessor if predecessor else None,
text_content=data,
)
# handle attachments
if file != "undefined":
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()
now = DateTime()
post_edit_kw = {
"start_date": now,
"follow_up_value": follow_up_object,
"text_content": data,
}
if predecessor is not None:
predecessor_value, = portal.portal_catalog(relative_url=predecessor)
post_edit_kw["predecessor_value"] = predecessor_value.getObject()
post.edit(**post_edit_kw)
post.publish()
# We need to reindex the object on server. So the page will get the post which
# just submmitted.
post.immediateReindexObject()
return
return post
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>follow_up, predecessor, data, file</string> </value>
<value> <string>follow_up, data, predecessor=None</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
......
return context.PostModule_createHTMLPost(
follow_up,
predecessor,
"<p>" + data.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;").replace(" ", " &nbsp;").replace("\n", "<br/>") + "</p>",
file,
follow_up=follow_up,
predecessor=predecessor,
data="<p>" + data.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;").replace(" ", " &nbsp;").replace("\n", "<br/>") + "</p>",
)
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>follow_up, predecessor, data, file</string> </value>
<value> <string>follow_up, data, predecessor=None</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
......
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