Commit a8051a33 authored by Ivan Tyagov's avatar Ivan Tyagov

Use generic contribute script.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32910 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b43c5820
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
A method invoked with parameters provided by the \n
contribute widget.\n
\n
**kw -- remaining params passed to the constructor\n
"""\n
from Products.ERP5.Document.Document import ConversionError\n
from xmlrpclib import Fault\n
from socket import error as SocketError\n
\n
Base_translateString = context.Base_translateString\n
\n
# return if no file was uploaded\n
if contribute_file is None or contribute_file.filename in (\'\', None,):\n
return context.Base_redirect(\'view\',\n
keep_items = dict(\n
portal_status_message = Base_translateString(\'No file was selected for contribution.\'), \n
editable_mode = context.REQUEST.get(\'editable_mode\', 0)))\n
\n
# Do some processing of parameters cause we do not use ERP5 Form here\n
if contribute_classification:\n
kw[\'classification\'] = contribute_classification\n
\n
if contribute_source_project:\n
kw[\'follow_up\'] = contribute_source_project\n
\n
if contribute_portal_type:\n
kw[\'portal_type\'] = contribute_portal_type\n
\n
if contribute_file is not None:\n
kw[\'file\'] = contribute_file\n
\n
# We want to discover metadata synchronously\n
kw[\'discover_metadata\'] = 0\n
\n
editable_mode = 1\n
file_name = getattr(contribute_file, \'filename\', None)\n
# try to ingest file\n
failure = 0\n
new_content = None\n
merged_content = None\n
\n
try:\n
new_content = context.portal_contributions.newContent(**kw)\n
new_content.processFile()\n
merged_content = new_content.Document_convertToBaseFormatAndDiscoverMetadata(file_name=file_name)\n
\n
except ConversionError, Fault:\n
# there are errors during ingestion content\n
failure = 1\n
msg = \'Sorry, there was a problem during conversion of your document.\'\n
except SocketError:\n
# conversion server is down\n
failure = 1\n
msg = \'Sorry, the conversion server is down. Please try again later.\'\n
except (TypeError, KeyError, AttributeError):\n
# there\'s an unknow error occured\n
failure = 1\n
msg = \'Sorry, unknow error occured.\'\n
\n
target = None\n
if merged_content is not None:\n
target = merged_content\n
elif new_content is not None:\n
target = new_content\n
else:\n
target = context\n
\n
if failure:\n
msg = Base_translateString(msg)\n
return target.Base_redirect(\'view\',\n
keep_items=dict(portal_status_message=msg,\n
editable_mode=0))\n
# successful ingestion, show appropriate message\n
if merged_content is not None and merged_content is not new_content:\n
msg = Base_translateString(\'Document successfully updated.\')\n
target = merged_content\n
else:\n
msg = Base_translateString(\'Document successfully created.\')\n
target = new_content\n
\n
# Change acquisition context of document, in order to get web section layout\n
target = context.restrictedTraverse(target.getRelativeUrl())\n
target_request = target.REQUEST\n
target_request.set(\'editable_mode\', editable_mode)\n
target_request.set(\'portal_status_message\', msg)\n
# clean up REQUEST as it is possible that this script is called\n
# on an another Document in an edit view (then fields will be passed in REQUEST \n
# overriding next form HTML generation in \'target.view()\' )\n
for key in target_request.form.keys():\n
if key.startswith(\'field_my_\'):\n
del target_request.form[key]\n
return target.view()\n
\n
# XXX Do not use redirect, as it leeds to conflict error with convertion process\n
# return target.Base_redirect(\'view\',\n
# keep_items=dict(portal_status_message=msg, \n
# editable_mode=editable_mode))\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>contribute_file=None, contribute_classification=None, contribute_source_project=None, contribute_portal_type=None, **kw</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>contribute_file</string>
<string>contribute_classification</string>
<string>contribute_source_project</string>
<string>contribute_portal_type</string>
<string>kw</string>
<string>Products.ERP5.Document.Document</string>
<string>ConversionError</string>
<string>xmlrpclib</string>
<string>Fault</string>
<string>socket</string>
<string>error</string>
<string>SocketError</string>
<string>_getattr_</string>
<string>context</string>
<string>Base_translateString</string>
<string>None</string>
<string>dict</string>
<string>_write_</string>
<string>editable_mode</string>
<string>getattr</string>
<string>file_name</string>
<string>failure</string>
<string>new_content</string>
<string>merged_content</string>
<string>_apply_</string>
<string>msg</string>
<string>TypeError</string>
<string>KeyError</string>
<string>AttributeError</string>
<string>target</string>
<string>target_request</string>
<string>_getiter_</string>
<string>key</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<none/>
<none/>
<none/>
<none/>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSite_contributeContent</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string># Do some processing of parameters cause we do not use ERP5 Form here\n
if link_classification:\n
kw[\'classification\'] = link_classification\n
\n
if link_source_project:\n
kw[\'source_project\'] = link_source_project\n
\n
if link_portal_type:\n
kw[\'portal_type\'] = link_portal_type\n
\n
if link_description:\n
kw[\'description\'] = link_description\n
\n
if link_url:\n
kw[\'url\'] = link_url\n
\n
kw[\'discover_metadata\'] = 0 # We want to discover metadata synchronously\n
\n
#try:\n
if 1:\n
new_content = context.portal_contributions.newContent(**kw)\n
new_content.discoverMetadata() # Consider putting an exception handler\n
msg = context.Base_translateString(\'Document successfully created.\')\n
target = new_content\n
editable_mode = 1\n
else:\n
#except Exception, e:\n
msg = \'There was a problem: ${exception}\'\n
msg = context.Base_translateString(msg, mapping=dict(exception=str(e)))\n
target = context\n
editable_mode = 0\n
\n
return target.Base_redirect(\'view\', keep_items=dict(portal_status_message=msg, editable_mode=editable_mode))\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>link_url=None, link_description=None, link_classification=None, link_source_project=None, link_portal_type=None, **kw</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>5</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>link_url</string>
<string>link_description</string>
<string>link_classification</string>
<string>link_source_project</string>
<string>link_portal_type</string>
<string>kw</string>
<string>_write_</string>
<string>_apply_</string>
<string>_getattr_</string>
<string>context</string>
<string>new_content</string>
<string>msg</string>
<string>target</string>
<string>editable_mode</string>
<string>dict</string>
<string>str</string>
<string>e</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<none/>
<none/>
<none/>
<none/>
<none/>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSite_linkContent</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -50,75 +50,126 @@ ...@@ -50,75 +50,126 @@
<tal:block metal:use-macro="here/global_definitions/macros/header_definitions"/>\n <tal:block metal:use-macro="here/global_definitions/macros/header_definitions"/>\n
</tal:block>\n </tal:block>\n
\n \n
<!-- Contribute file tab -->\n
\n
<div class="tabber" id="mytabber2">\n <div class="tabber" id="mytabber2">\n
<form action="Base_contribute" \n
enctype="multipart/form-data" \n
method="post"\n
name="contribute_file_form">\n
<div class="tabbertab">\n <div class="tabbertab">\n
<h2 i18n:translate="" i18n:domain="ui">Contribute</h2>\n <h2 i18n:translate="" \n
i18n:domain="ui">Contribute</h2>\n
<div class="fieldset">\n <div class="fieldset">\n
<div>\n <div>\n
<label for="contribute_portal_type" i18n:translate="" i18n:domain="ui">Type</label>\n <label for="portal_type" \n
<select size="1" name="contribute_portal_type" id="portal_type" onchange="toggleMakeTemplateButton(this);">\n i18n:translate="" \n
<option value="" i18n:translate="" i18n:domain="ui">-- Select Document Type --</option>\n i18n:domain="ui">Type</label>\n
<select size="1" \n
name="portal_type" \n
id="portal_type" \n
onchange="toggleMakeTemplateButton(this);">\n
<option value="" \n
i18n:translate="" \n
i18n:domain="ui">-- Select Document Type --</option>\n
<tal:block tal:repeat="ptype here/getPortalTemplateDocumentTypeList">\n <tal:block tal:repeat="ptype here/getPortalTemplateDocumentTypeList">\n
<option \n <option tal:content="ptype" \n
tal:content="ptype" tal:attributes="value ptype"\n tal:attributes="value ptype"\n
value="" i18n:translate="" i18n:domain="ui">Report</option>\n value="" \n
i18n:translate="" \n
i18n:domain="ui"/>\n
</tal:block>\n </tal:block>\n
<option value="" i18n:translate="" i18n:domain="ui">-- Any Other Document Type --</option>\n <option value="" \n
i18n:translate="" \n
i18n:domain="ui">-- Any Other Document Type --</option>\n
</select>\n </select>\n
<input type="file" name="contribute_file" size="30" />\n <input type="hidden" \n
name="synchronous_metadata_discovery" \n
value="1"/>\n
<input type="hidden" \n
name="redirect_to_document" \n
value="1"/>\n
<input type="file" \n
name="file" size="30" />\n
</div>\n </div>\n
<!--<a onclick="setMailString();" id="mail_contribute_button" href="mailto:dms@dms.nexedi.com?subject=Contribution&body=">\n \n
<img src="au_icons/kmail.png" align="right" alt="contribute by mail" title="contribute by mail"/>\n
</a>-->\n
<div style="float:left"\n <div style="float:left"\n
tal:define="contribute_prefix string:contribute_">\n tal:define="contribute_prefix string:">\n
<div metal:use-macro="here/WebSite_viewContributePropertyRenderer/macros/contribute_properties">\n <div metal:use-macro="here/WebSite_viewContributePropertyRenderer/macros/contribute_properties"/>\n
Theme\n
</div>\n
</div>\n </div>\n
\n \n
<div style="float:right; margin-top:10px;">\n <div style="float:right; margin-top:10px;">\n
<a onclick="setMailString();" id="mail_contribute_button"\n <a onclick="setMailString();" \n
href="mailto:dms@dms.nexedi.com?subject=Contribution&body="\n id="mail_contribute_button"\n
tal:define="ingestion_address here/portal_preferences/getPreferredDocumentEmailIngestionAddress|nothing"\n tal:define="ingestion_address here/portal_preferences/getPreferredDocumentEmailIngestionAddress|nothing"\n
tal:condition="ingestion_address"\n tal:condition="ingestion_address"\n
tal:attributes="href string:${ingestion_address}?subject=Contribution&body=">\n tal:attributes="href string:${ingestion_address}?subject=Contribution&body=">\n
<img src="send_by_mail" border="0"/>\n <img src="send_by_mail" border="0"/>\n
<tal:block i18n:translate="" i18n:domain="ui">Click here to contribute by email.</tal:block></a>\n <tal:block \n
&nbsp;\n i18n:translate="" \n
<input i18n:domain="ui" i18n:attributes="value" type="submit" name="Memo_makeOOoTemplate:method" value="Make Template" id="maketemplatebutton" disabled="disabled"\n i18n:domain="ui">Click here to contribute by email.</tal:block></a>\n
style="width:100px;background-image:none;"/>\n \n
&nbsp;\n <input i18n:domain="ui" \n
<input i18n:domain="ui" i18n:attributes="value" type="submit" name="WebSite_contributeContent:method" value="Contribute"/>\n i18n:attributes="value" \n
type="submit" \n
name="Base_contribute:method" \n
value="Contribute"/>\n
</div>\n </div>\n
\n
\n
</div>\n </div>\n
\n \n
<div class="clear"></div>\n <div class="clear"></div>\n
</div>\n </div>\n
</form>\n
\n \n
<div class="tabbertab">\n <!-- Contribute link tab -->\n
<h2 i18n:translate="" i18n:domain="ui">Link</h2>\n <div class="tabbertab">\n
<div class="fieldset tabbertabcont">\n <form action="Base_contribute" \n
<div>\n enctype="multipart/form-data" \n
<label for="url" value="" i18n:translate="" i18n:domain="ui">URL</label>\n method="post"\n
<input type="text" name="link_url" id="url" size="80" value="http://" />\n name="contribute_url_form">\n
<a href="" target="_blank" onclick="return setLink(this)" value="" i18n:translate="" i18n:domain="ui">Preview</a>\n <h2 i18n:translate="" i18n:domain="ui">Link</h2>\n
</div>\n <div class="fieldset tabbertabcont">\n
<tal:block tal:define="contribute_prefix string:link_">\n <div>\n
<div metal:use-macro="here/WebSite_viewContributePropertyRenderer/macros/contribute_properties">\n <label for="url" \n
Theme\n i18n:translate="" \n
</div>\n i18n:domain="ui">URL</label>\n
</tal:block>\n <input type="text" \n
<div>\n name="url" \n
<label for="link_description" value="" i18n:translate="" i18n:domain="ui">Description</label>\n id="url" \n
<textarea cols="80" rows="2" name="link_description"></textarea>\n size="80" \n
</div>\n value="http://" />\n
<a href="" \n
target="_blank" \n
onclick="return setLink(this)" \n
value="" \n
i18n:translate="" \n
i18n:domain="ui">Preview</a>\n
</div>\n </div>\n
<input i18n:domain="ui" i18n:attributes="value" style="float:right" type="submit" name="WebSite_linkContent:method" value="Contribute"/>\n <tal:block tal:define="contribute_prefix string:">\n
<div class="clear"></div>\n <div metal:use-macro="here/WebSite_viewContributePropertyRenderer/macros/contribute_properties"/>\n
</div>\n </tal:block>\n
<div>\n
<label for="description" \n
i18n:translate="" \n
i18n:domain="ui">Description</label>\n
<textarea cols="80" \n
rows="2" \n
name="description"></textarea>\n
</div>\n
</div>\n
\n
<input type="hidden" \n
name="redirect_url" \n
tal:attributes="value python: here.getWebSiteValue().absolute_url()"/> \n
<input i18n:domain="ui" \n
i18n:attributes="value" \n
style="float:right" \n
type="submit" \n
name="Base_contribute:method" \n
value="Contribute"/>\n
<div class="clear"></div>\n
</form>\n
</div>\n
\n \n
<div class="tabbertab"\n <div class="tabbertab"\n
tal:define="user here/portal_membership/getAuthenticatedMember">\n tal:define="user here/portal_membership/getAuthenticatedMember">\n
......
907 908
\ No newline at end of file \ No newline at end of file
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