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 ...@@ -69,16 +69,23 @@ else:\n
listbox = []\n listbox = []\n
int_index = 1\n int_index = 1\n
\n \n
if slide_type == \'Screenshot\':\n image_id = \'\'\n
tested = True\n
\n \n
if slide_type in [\'Illustration\',\'Screenshot\']:\n if slide_type in [\'Illustration\',\'Screenshot\']:\n
test_page_path = session[\'test_page_path\']\n test_page_path = session[\'test_page_path\']\n
test_page = context.restrictedTraverse(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_id = test_page.TestPage_getNextImageID(chapter_title, slide_type)\n
image = test_page.TestPage_uploadImage(image_id, file, batch_mode = True)\n image = test_page.TestPage_uploadImage(image_id, file, batch_mode = True)\n
else:\n
image_id = \'\'\n
\n \n
listbox.append(newTempBase(context.getPortalObject(),\n listbox.append(newTempBase(context.getPortalObject(),\n
\'\',\n \'\',\n
...@@ -94,14 +101,15 @@ listbox.append(newTempBase(context.getPortalObject(),\n ...@@ -94,14 +101,15 @@ listbox.append(newTempBase(context.getPortalObject(),\n
))\n ))\n
\n \n
session[\'listbox\'] = listbox\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> ]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <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>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -57,9 +57,9 @@ ...@@ -57,9 +57,9 @@
"""\n """\n
\n \n
from Products.ERP5Type.Document import newTempBase\n from Products.ERP5Type.Document import newTempBase\n
\n
# Add the last chapter to the listbox\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 \n
translateString = context.Base_translateString\n translateString = context.Base_translateString\n
portal_status_message = ""\n portal_status_message = ""\n
...@@ -72,17 +72,7 @@ author = session[\'author\']\n ...@@ -72,17 +72,7 @@ author = session[\'author\']\n
author_mail = session[\'author_mail\']\n author_mail = session[\'author_mail\']\n
\n \n
# Headers and first chapter/slide\n # Headers and first chapter/slide\n
text_content = """<!DOCTYPE html>\n text_content = """<section class="master">\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
<h1>""" + title + """</h1>\n <h1>""" + title + """</h1>\n
""" + listbox[0].slide_content\n """ + listbox[0].slide_content\n
\n \n
...@@ -128,20 +118,19 @@ for chapter in listbox[1:]:\n ...@@ -128,20 +118,19 @@ for chapter in listbox[1:]:\n
\n \n
# let\'s add a template test to this chapter\n # let\'s add a template test to this chapter\n
if chapter.tested:\n if chapter.tested:\n
text_content += """\n text_content +="""\n
<test>\n <test>"""\n
<table class="test" cellpadding="1" cellspacing="1" border="1" style="display:none;">"""\n
if first:\n if first:\n
text_content += """\n text_content +="""\n
<thead>\n <span metal:use-macro="container/ERP5RunMyDocs_initTest/macros/init_test_environment" style="display:none;"> init</span>"""\n
<tr><th rowspan="1" colspan="3">""" + session[\'title\'] + """</th></tr>\n
</thead>"""\n
first = False\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 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 <tr>\n
\t <td>selectAndWait</td>\n \t <td>selectAndWait</td>\n
\t <td>name=select_module</td>\n \t <td>name=select_module</td>\n
...@@ -167,20 +156,17 @@ for chapter in listbox[1:]:\n ...@@ -167,20 +156,17 @@ for chapter in listbox[1:]:\n
</section>\n </section>\n
"""\n """\n
\n \n
text_content +="""\n
</body>\n
</html>"""\n
\n
test_page.setTextContent(text_content)\n test_page.setTextContent(text_content)\n
\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> ]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <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>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -87,6 +87,7 @@ ...@@ -87,6 +87,7 @@
<string>your_title</string> <string>your_title</string>
<string>your_chapter_title</string> <string>your_chapter_title</string>
<string>your_slide_type</string> <string>your_slide_type</string>
<string>your_image_url</string>
<string>your_file</string> <string>your_file</string>
<string>your_slide_content</string> <string>your_slide_content</string>
<string>your_text_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 @@ ...@@ -54,7 +54,13 @@
Create an image object and upload the image if necessary\n Create an image object and upload the image if necessary\n
"""\n """\n
\n \n
translateString = context.Base_translateString\n
\n
msg = \'Slide created.\'\n msg = \'Slide created.\'\n
\n
if edit_mode == 1:\n
msg = \'Slide updated.\'\n
\n
def createImage(image_id):\n def createImage(image_id):\n
return context.newContent(portal_type = \'Embedded File\',\n return context.newContent(portal_type = \'Embedded File\',\n
title = image_id,\n title = image_id,\n
...@@ -80,16 +86,18 @@ if slide_type in [\'Screenshot\', \'Illustration\']:\n ...@@ -80,16 +86,18 @@ if slide_type in [\'Screenshot\', \'Illustration\']:\n
msg += \' Image \' + image_id + \' created.\'\n msg += \' Image \' + image_id + \' created.\'\n
\n \n
if not(file is None or not file):\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 msg += \' Image uploaded.\'\n
\n \n
if batch_mode:\n if batch_mode:\n
return image\n return image\n
\n \n
translateString = context.Base_translateString\n form_id = context.REQUEST.get(\'dialog_id\', None)\n
portal_status_message = translateString(msg)\n context.Base_redirect(form_id,\n
context.Base_redirect(\'TestPage_viewSlideCreator\', \n keep_items = dict(portal_status_message=translateString(msg)))\n
keep_items = dict(portal_status_message=portal_status_message))\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
......
35 36
\ 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