Commit e975c723 authored by Rafael Monnerat's avatar Rafael Monnerat

Accept url for Slide image

This changes permit use URL instead local images all the time.
parent 63202dd8
......@@ -69,16 +69,23 @@ else:\n
listbox = []\n
int_index = 1\n
\n
if slide_type == \'Screenshot\':\n
tested = True\n
image_id = \'\'\n
\n
if slide_type in [\'Illustration\',\'Screenshot\']:\n
test_page_path = session[\'test_page_path\']\n
test_page = context.restrictedTraverse(test_page_path)\n
\n
if slide_type == \'Illustration\':\n
if image_url != "":\n
image_id = image_url\n
else:\n
image_id = test_page.TestPage_getNextImageID(chapter_title, slide_type)\n
image = test_page.TestPage_uploadImage(image_id, file, batch_mode = True)\n
\n
if slide_type == \'Screenshot\':\n
tested = True\n
image_id = test_page.TestPage_getNextImageID(chapter_title, slide_type)\n
image = test_page.TestPage_uploadImage(image_id, file, batch_mode = True)\n
else:\n
image_id = \'\'\n
\n
listbox.append(newTempBase(context.getPortalObject(),\n
\'\',\n
......@@ -94,14 +101,15 @@ listbox.append(newTempBase(context.getPortalObject(),\n
))\n
\n
session[\'listbox\'] = listbox\n
return context.Base_redirect(\'TestPageModule_viewChapterCreationWizard\', keep_items = dict(portal_status_message=portal_status_message))\n
return context.Base_redirect(\'TestPageModule_viewChapterCreationWizard\', \n
keep_items = dict(portal_status_message=portal_status_message))\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>chapter_title, slide_type, file, text_content, slide_content, tested, **kw</string> </value>
<value> <string>chapter_title, slide_type, image_url, file, text_content, slide_content, tested, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -57,9 +57,9 @@
"""\n
\n
from Products.ERP5Type.Document import newTempBase\n
\n
# Add the last chapter to the listbox\n
context.TestPageModule_createChapter(chapter_title, slide_type, file, text_content, slide_content, tested, **kw)\n
context.TestPageModule_createChapter(chapter_title, slide_type, image_url, \n
file, text_content, slide_content, tested, **kw)\n
\n
translateString = context.Base_translateString\n
portal_status_message = ""\n
......@@ -72,17 +72,7 @@ author = session[\'author\']\n
author_mail = session[\'author_mail\']\n
\n
# Headers and first chapter/slide\n
text_content = """<!DOCTYPE html>\n
<html>\n
<head>\n
<base href="" />\n
<meta http-equiv="content-type" content="text/html; charset=UTF-8">\n
<link href="http://fonts.googleapis.com/css?family=Oswald" rel="stylesheet">\n
<meta charset="utf-8">\n
<title>""" + title + """</title>\n
</head>\n
<body>\n
<section class="master">\n
text_content = """<section class="master">\n
<h1>""" + title + """</h1>\n
""" + listbox[0].slide_content\n
\n
......@@ -128,20 +118,19 @@ for chapter in listbox[1:]:\n
\n
# let\'s add a template test to this chapter\n
if chapter.tested:\n
text_content += """\n
<test>\n
<table class="test" cellpadding="1" cellspacing="1" border="1" style="display:none;">"""\n
text_content +="""\n
<test>"""\n
if first:\n
text_content += """\n
<thead>\n
<tr><th rowspan="1" colspan="3">""" + session[\'title\'] + """</th></tr>\n
</thead>"""\n
text_content +="""\n
<span metal:use-macro="container/ERP5RunMyDocs_initTest/macros/init_test_environment" style="display:none;"> init</span>"""\n
first = False\n
\n
text_content +="""\n
<table class="test" cellpadding="1" cellspacing="1" border="1" style="display:none;">\n
<tbody>"""\n
\n
\n
text_content += """\n
<tbody>\n
<tr>\n
<td colspan=3 >&lt;span metal:use-macro="container/ERP5RunMyDocs_initTest/macros/init_test_environment" style="display:none;"&gt;init&lt;/span&gt;</td>\n
</tr>\n
<tr>\n
\t <td>selectAndWait</td>\n
\t <td>name=select_module</td>\n
......@@ -167,20 +156,17 @@ for chapter in listbox[1:]:\n
</section>\n
"""\n
\n
text_content +="""\n
</body>\n
</html>"""\n
\n
test_page.setTextContent(text_content)\n
\n
return test_page.Base_redirect(\'view\', keep_items = dict(portal_status_message=portal_status_message))\n
return test_page.Base_redirect(\'view\', \n
keep_items = dict(portal_status_message=portal_status_message))\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>chapter_title, slide_type, file, text_content, slide_content, tested, **kw</string> </value>
<value> <string>chapter_title, slide_type, image_url, file, text_content, slide_content, tested, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -87,6 +87,7 @@
<string>your_title</string>
<string>your_chapter_title</string>
<string>your_slide_type</string>
<string>your_image_url</string>
<string>your_file</string>
<string>your_slide_content</string>
<string>your_text_content</string>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>description</string>
<string>display_width</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_image_url</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>description</string> </key>
<value> <string>The URL to the image, you can use relative urls or image reference.</string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <int>90</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_view_mode_title</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Image URL</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -54,7 +54,13 @@
Create an image object and upload the image if necessary\n
"""\n
\n
translateString = context.Base_translateString\n
\n
msg = \'Slide created.\'\n
\n
if edit_mode == 1:\n
msg = \'Slide updated.\'\n
\n
def createImage(image_id):\n
return context.newContent(portal_type = \'Embedded File\',\n
title = image_id,\n
......@@ -80,16 +86,18 @@ if slide_type in [\'Screenshot\', \'Illustration\']:\n
msg += \' Image \' + image_id + \' created.\'\n
\n
if not(file is None or not file):\n
image.edit(file=file, data=file.read(), filename=file.filename)\n
image.edit(file=file, \n
data=file.read(), \n
filename=file.filename)\n
\n
msg += \' Image uploaded.\'\n
\n
if batch_mode:\n
return image\n
\n
translateString = context.Base_translateString\n
portal_status_message = translateString(msg)\n
context.Base_redirect(\'TestPage_viewSlideCreator\', \n
keep_items = dict(portal_status_message=portal_status_message))\n
form_id = context.REQUEST.get(\'dialog_id\', None)\n
context.Base_redirect(form_id,\n
keep_items = dict(portal_status_message=translateString(msg)))\n
</string> </value>
</item>
<item>
......
35
\ No newline at end of file
36
\ 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