Commit 1a9e95bb authored by Boris Kocherov's avatar Boris Kocherov

erp5_officejs: avoiding edit of documents if converter is not available, thanks @cedric.leninivin

parent 4eba4662
...@@ -332,6 +332,13 @@ ...@@ -332,6 +332,13 @@
documentType = options.portal_type;\n documentType = options.portal_type;\n
} else {\n } else {\n
documentType = magic_to_format_map[options.value.substring(0, 5)];\n documentType = magic_to_format_map[options.value.substring(0, 5)];\n
if (documentType === undefined) {\n
g.props\n
.element\n
.getElementsByClassName(placeholder)[0]\n
.textContent = options.value;\n
return {};\n
}\n
}\n }\n
return g.setFillStyle()\n return g.setFillStyle()\n
.push(function (size) {\n .push(function (size) {\n
...@@ -537,7 +544,7 @@ ...@@ -537,7 +544,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>948.36349.33632.18926</string> </value> <value> <string>948.52265.56945.58436</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -555,7 +562,7 @@ ...@@ -555,7 +562,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1453142306.9</float> <float>1454097524.73</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string># XXX not work for readonly documents\n <value> <string># XXX not work for readonly documents\n
from Products.ERP5.Document.Document import NotConvertedError\n from Products.ERP5.Document.Document import NotConvertedError, ConversionError\n
from Products.ERP5Type.Utils import sleep\n from Products.ERP5Type.Utils import sleep\n
\n \n
portal_type = context.getPortalType()\n portal_type = context.getPortalType()\n
...@@ -66,22 +66,30 @@ portal_type_empty_map = {\n ...@@ -66,22 +66,30 @@ portal_type_empty_map = {\n
portal_type_format_map = {\n portal_type_format_map = {\n
"Spreadsheet": "xlsy",\n "Spreadsheet": "xlsy",\n
"Text": "docy",\n "Text": "docy",\n
# "Presentation": "ppty",\n "Presentation": "ppty",\n
}\n }\n
file_format = portal_type_format_map.get(portal_type, None)\n file_format = portal_type_format_map.get(portal_type, None)\n
if file_format:\n if file_format:\n
if data:\n if data:\n
if ((filename and not filename.endswith(\'.\' + file_format)) or \n if ((filename and not filename.endswith(\'.\' + file_format)) or \n
not content_type.startswith("application/yformat.")):\n not content_type.startswith("application/yformat.")):\n
converted = False\n
for try_count in range(3):\n for try_count in range(3):\n
try:\n try:\n
metadata, data = context.convert(format=file_format)\n content_type, data = context.convert(format=file_format)\n
converted = True\n
break\n break\n
except NotConvertedError:\n except NotConvertedError:\n
data = \'ERRO;NotConvertedError;Please try reload this page again latter.\'\n
sleep()\n sleep()\n
continue\n continue\n
context.setData(data)\n except ConversionError:\n
context.setContentType(metadata)\n data = \'ERRO;ConversionError;Conversion error on Cloudooo server. Please contact support.\'\n
if converted:\n
context.setData(data)\n
context.setContentType(content_type)\n
else:\n
return data\n
else:\n else:\n
data = portal_type_empty_map.get(portal_type, None)\n data = portal_type_empty_map.get(portal_type, None)\n
if data:\n if data:\n
......
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