Commit ab1a8420 authored by Rafael Monnerat's avatar Rafael Monnerat

Use getDocumentValue API to select the appropriate image to upload based on it's reference.

parent e00cf198
...@@ -53,29 +53,31 @@ ...@@ -53,29 +53,31 @@
<value> <string>"""\n <value> <string>"""\n
Upload a screenshot taken by the test to ERP5\n Upload a screenshot taken by the test to ERP5\n
"""\n """\n
global msg\n from Products.ERP5Type.Log import log\n
msg = \'\'\n \n
data_uri = context.REQUEST.form.get(\'data_uri\', \'default\')\n data_uri = context.REQUEST.form.get(\'data_uri\', \'default\')\n
\n \n
image = context.portal_catalog.getResultValue(reference=image_reference, \n image_module = getattr(context, "image_module", None)\n
portal_type="Image")\n if image_module is None:\n
return "erp5_dms is not Installed"\n
\n
image = image_module.getPortalObject().WebSection_getDocumentValue(\n
name=image_reference)\n
\n \n
if image is None:\n if image is None or image.getPortalType() != "Image":\n
# Image is an embedded file\n # Image is an embedded file or not an image\n
return "Image: " + str(image_reference) + " not found"\n return "Image: " + str(image_reference) + " not found"\n
\n \n
image.setContentType(\'image/png\')\n image.setContentType(\'image/png\')\n
data_text = data_uri.read()\n data_text = data_uri.read()\n
msg += \'dataUri : \' + data_text + \'\\n\'\n
data = data_text.decode(\'base64\')\n data = data_text.decode(\'base64\')\n
msg += \'data : \' + data + \'\\n\'\n \n
image.edit(data=data, \n image.edit(data=data, \n
base_data=data, \n #base_data=data,\n
filename=str(image_reference) + \'.png\', \n filename=str(image_reference) + \'.png\', \n
content_type = \'image/png\')\n content_type = \'image/png\')\n
\n \n
context.Zuite_updateImage(image)\n context.Zuite_updateImage(image)\n
msg += \'done\'\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
......
49 50
\ 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