Commit b5153d8b authored by Jérome Perrin's avatar Jérome Perrin

post: review Post API

* add a `source_reference` field to store message-id
* store the raw content "as is" - there is not preview for this reason (
  because it might be unsafe html or whatever)
* remove proxy roles on scripts. User must have permission.
* minor simplifications
parent 081e9f28
......@@ -73,6 +73,7 @@
<value>
<list>
<string>my_title</string>
<string>my_source_reference</string>
</list>
</value>
</item>
......
# XXX do we need two scripts ??
portal = context.getPortalObject()
traverse = context.getPortalObject().restrictedTraverse
# create an HTML Post
post_module = portal.post_module
......@@ -6,14 +9,16 @@ post_module = portal.post_module
now = DateTime()
post_edit_kw = {
"start_date": now,
"follow_up_value": context.getPortalObject().restrictedTraverse(follow_up),
"follow_up_value": traverse(follow_up),
"text_content": data,
"source_reference": source_reference,
"title": title,
}
if predecessor not in (None, ""):
predecessor_value, = portal.portal_catalog(relative_url=predecessor, limit=2)
post_edit_kw["predecessor_value"] = predecessor_value.getObject()
if predecessor:
post_edit_kw["predecessor"] = traverse(predecessor)
post = post_module.newContent(
immediate_reindex=immediate_reindex_context_manager,
portal_type='HTML Post',
**post_edit_kw
)
......
......@@ -50,16 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>follow_up, data, predecessor=None, immediate_reindex_context_manager=None</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
<value> <string>follow_up, data, predecessor=None, source_reference=None, title=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
return context.PostModule_createHTMLPost(
title=data.splitlines()[0][:30] if data else None,
source_reference=source_reference,
data=data,
follow_up=follow_up,
predecessor=predecessor,
data="<p>" + data.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;").replace(" ", " &nbsp;").replace("\n", "<br/>") + "</p>",
immediate_reindex_context_manager=immediate_reindex_context_manager,
)
......@@ -50,16 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>follow_up, data, predecessor=None, immediate_reindex_context_manager=None</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
<value> <string>follow_up, data, source_reference, predecessor=None</string> </value>
</item>
<item>
<key> <string>id</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