Commit b7b09af9 authored by Ivan Tyagov's avatar Ivan Tyagov

Use generic contribute script.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32907 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2f778c6d
<?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
# 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
# set file_name\n
new_content.setSourceReference(file_name)\n
if new_content.isSupportBaseDataConversion():\n
new_content.processFile()\n
merged_content = new_content.Document_convertToBaseFormatAndDiscoverMetadata(file_name=file_name)\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 = context.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 = context.Base_translateString(\'Document successfully updated.\')\n
target = merged_content\n
else:\n
msg = context.Base_translateString(\'Document successfully created.\')\n
target = new_content\n
\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>_write_</string>
<string>None</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>_getattr_</string>
<string>context</string>
<string>msg</string>
<string>TypeError</string>
<string>KeyError</string>
<string>AttributeError</string>
<string>target</string>
<string>dict</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>ERP5Site_contributeContent</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -41,47 +41,68 @@
<tal:block xmlns:tal="http://xml.zope.org/namespaces/tal"\n
xmlns:i18n="http://xml.zope.org/namespaces/i18n"\n
tal:define="dummy python: request.RESPONSE.setHeader(\'Content-Type\', \n
\'text/html;; charset=utf-8\');">\n
tal:define="dummy python: request.RESPONSE.setHeader(\'Content-Type\', \n
\'text/html;; charset=utf-8\');">\n
<div class="fieldset hidden_label">\n
\n
<div>\n
<input type="file" name="contribute_file" size="30" />\n
<input type="file" name="file" size="30" />\n
</div>\n
\n
<div>\n
<label for="classification" \n
value="" \n
i18n:translate="" \n
i18n:domain="ui">Classification</label>\n
<select size="1" name="classification" id="classification">\n
<option value=""\n
i18n:translate="" \n
i18n:domain="ui">-- Select Classification --</option>\n
<option tal:repeat="item python:[c for c in here.portal_categories.classification.getCategoryChildTranslatedLogicalPathItemList(local_sort_id=\'translated_title\')[1:] if len(c[1].split(\'/\'))>1]" \n
tal:content="python:item[0]" \n
tal:attributes="value python:item[1]"/>\n
</select>\n
</div>\n
<div>\n
<label for="source_project" \n
value="" \n
i18n:translate="" \n
i18n:domain="ui">Project</label>\n
<select size="1" \n
id="source_project" \n
name="source_project"\n
tal:define="ticket_module nocall:here/ticket_module|nothing;\n
project_module nocall:here/project_module|nothing;">\n
<option value=""\n
i18n:translate="" \n
i18n:domain="ui">-- Select Project --</option>\n
<option tal:condition="project_module"\n
tal:repeat="item python:[(o.getTitle(),o.getRelativeUrl()) \n
for o in project_module.searchFolder()]" \n
tal:content="python:item[0]" \n
tal:attributes="value python:item[1]"/>\n
<option tal:condition="ticket_module"\n
tal:repeat="item python:[(o.getTitle(),o.getRelativeUrl()) \n
for o in ticket_module.searchFolder()]" \n
tal:content="python:item[0]" \n
tal:attributes="value python:item[1]"/>\n
</select>\n
</div>\n
<tal:block tal:define="contribute_prefix string:contribute_">\n
<div>\n
<label for="classification" value="" i18n:translate="" i18n:domain="ui">Classification</label>\n
<select size="1" name="classification" id="classification"\n
tal:attributes="name string:${contribute_prefix}classification">\n
<option value="" value="" i18n:translate="" i18n:domain="ui">-- Select Classification --</option>\n
<option tal:repeat="item python:[c for c in here.portal_categories.classification.getCategoryChildTranslatedLogicalPathItemList(local_sort_id=\'translated_title\')[1:] if len(c[1].split(\'/\'))>1]" tal:content="python:item[0]" tal:attributes="value python:item[1]">\n
Agricultural Development\n
</option>\n
</select>\n
</div>\n
<div>\n
<label for="source_project" value="" i18n:translate="" i18n:domain="ui">Project</label>\n
<select size="1" id="source_project" name="source_project"\n
tal:attributes="name string:${contribute_prefix}source_project"\n
tal:define="ticket_module nocall:here/ticket_module|nothing;\n
project_module nocall:here/project_module|nothing;">\n
<option value="" value="" i18n:translate="" i18n:domain="ui">-- Select Project --</option>\n
<option tal:condition="project_module"\n
tal:repeat="item python:[(o.getTitle(),o.getRelativeUrl()) for o in project_module.searchFolder()]" tal:content="python:item[0]" tal:attributes="value python:item[1]">\n
Project Name\n
</option>\n
<option tal:condition="ticket_module"\n
tal:repeat="item python:[(o.getTitle(),o.getRelativeUrl()) for o in ticket_module.searchFolder()]" tal:content="python:item[0]" tal:attributes="value python:item[1]">\n
Ticket Name\n
</option>\n
</select>\n
</div>\n
</tal:block>\n
\n
<p class="clear" />\n
\n
<div style="float:none; margin-top:10px;">\n
<input type="submit" i18n:attributes="value" i18n:domain="ui" name="ERP5Site_uploadContributeContent:method" value="Contribute"/>\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="submit" \n
i18n:attributes="value" \n
i18n:domain="ui" name="Base_contribute:method" value="Contribute"/>\n
</div>\n
\n
</div>\n
</tal:block>\n
......
903
\ No newline at end of file
904
\ 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