From c3620ed3e658008ddc368171fd497efc3ce2b10e Mon Sep 17 00:00:00 2001
From: Mame Coumba Sall <mame@nexedi.com>
Date: Fri, 12 Feb 2010 16:29:16 +0000
Subject: [PATCH] Clean WebSection_newWebPage *Rename the script *Keep the
 existing categories on WebPage instead of deleting them.

*Remove the reference generated on the WebPage.

*Redirect to the web page in the context of the web section (in order to view the section in the breadcrumb).

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32509 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../portal_types/Web%20Section/new_page.xml   |  6 ++--
 ...ge.xml => WebSection_createNewWebPage.xml} | 31 ++++++++++++-------
 bt5/erp5_web/bt/revision                      |  2 +-
 3 files changed, 25 insertions(+), 14 deletions(-)
 rename bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/{WebSection_newWebPage.xml => WebSection_createNewWebPage.xml} (85%)

diff --git a/bt5/erp5_web/ActionTemplateItem/portal_types/Web%20Section/new_page.xml b/bt5/erp5_web/ActionTemplateItem/portal_types/Web%20Section/new_page.xml
index 96b9f99a27..62a91d066f 100644
--- a/bt5/erp5_web/ActionTemplateItem/portal_types/Web%20Section/new_page.xml
+++ b/bt5/erp5_web/ActionTemplateItem/portal_types/Web%20Section/new_page.xml
@@ -33,7 +33,9 @@
         </item>
         <item>
             <key> <string>description</string> </key>
-            <value> <string></string> </value>
+            <value>
+              <none/>
+            </value>
         </item>
         <item>
             <key> <string>icon</string> </key>
@@ -77,7 +79,7 @@
       <dictionary>
         <item>
             <key> <string>text</string> </key>
-            <value> <string>string:${object_url}/WebSection_newWebPage</string> </value>
+            <value> <string>string:${object_url}/WebSection_createNewWebPage</string> </value>
         </item>
       </dictionary>
     </pickle>
diff --git a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_newWebPage.xml b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_createNewWebPage.xml
similarity index 85%
rename from bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_newWebPage.xml
rename to bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_createNewWebPage.xml
index d5c9ce1cb7..d2aea2a411 100644
--- a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_newWebPage.xml
+++ b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_createNewWebPage.xml
@@ -53,11 +53,13 @@
         </item>
         <item>
             <key> <string>_body</string> </key>
-            <value> <string>request = context.REQUEST\n
+            <value> <string encoding="cdata"><![CDATA[
+
+request = context.REQUEST\n
 portal = context.getPortalObject()\n
 title = context.getTitle(\'Unknown\')\n
 translateString = context.Base_translateString\n
-web_page_module = portal.getDefaultModule(\'Web Page\')\n
+web_page_module = context.web_page_module\n
 \n
 # Find the applicable language\n
 language = portal.Localizer.get_selected_language()\n
@@ -65,19 +67,24 @@ language = portal.Localizer.get_selected_language()\n
 # Create a new empty page\n
 web_page = web_page_module.newContent(portal_type = \'Web Page\', \n
                                       title="New Page of Section %s" % title,\n
-                                      reference="default-%s" % context.getId(),\n
                                       version="1", language=language)\n
 \n
+\n
 # Copy categories into new Web Page\n
 category_list = context.getMembershipCriterionCategoryList()\n
-web_page.setCategoryList(category_list)\n
+web_page.setCategoryList(web_page.getCategoryList() + category_list)\n
 \n
 # Return the new page in the section context\n
-return web_page.Base_redirect(\'view\',\n
-          keep_items = dict(editable_mode=1,\n
-              portal_status_message=translateString("New Web Page of section ${web_section}.",\n
-          mapping = dict(web_section=title))))\n
-</string> </value>
+editable_mode = 1\n
+message = translateString("New Web Page of section %s." %(context.getTitle()))\n
+redirect_url = \'%s/%s/view?portal_status_message=%s&editable_mode:int=%s\' % (\n
+            context.absolute_url(), web_page.getRelativeUrl(),message,editable_mode)\n
+\n
+# return to the new page in the section context\n
+return context.REQUEST.RESPONSE.redirect(redirect_url)\n
+
+
+]]></string> </value>
         </item>
         <item>
             <key> <string>_code</string> </key>
@@ -123,7 +130,9 @@ return web_page.Base_redirect(\'view\',\n
                             <string>language</string>
                             <string>web_page</string>
                             <string>category_list</string>
-                            <string>dict</string>
+                            <string>editable_mode</string>
+                            <string>message</string>
+                            <string>redirect_url</string>
                           </tuple>
                         </value>
                     </item>
@@ -140,7 +149,7 @@ return web_page.Base_redirect(\'view\',\n
         </item>
         <item>
             <key> <string>id</string> </key>
-            <value> <string>WebSection_newWebPage</string> </value>
+            <value> <string>WebSection_createNewWebPage</string> </value>
         </item>
         <item>
             <key> <string>warnings</string> </key>
diff --git a/bt5/erp5_web/bt/revision b/bt5/erp5_web/bt/revision
index 7bfae052e1..1b003ab28f 100644
--- a/bt5/erp5_web/bt/revision
+++ b/bt5/erp5_web/bt/revision
@@ -1 +1 @@
-905
\ No newline at end of file
+906
\ No newline at end of file
-- 
2.30.9