[Erp5-report] r34467 jerome - in /erp5/trunk/products/ERP5/bootstrap/erp5_core: SkinTemplat...

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Apr 12 15:59:12 CEST 2010


Author: jerome
Date: Mon Apr 12 15:59:09 2010
New Revision: 34467

URL: http://svn.erp5.org?rev=34467&view=rev
Log:
When making a template, if a template with same title already exists, replace it. This way we can easilly update an existing template.
Also check that the user has "Add portal content" permission in the preference.

Modified:
    erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_makeTemplateFromDocument.xml
    erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision

Modified: erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_makeTemplateFromDocument.xml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_makeTemplateFromDocument.xml?rev=34467&r1=34466&r2=34467&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_makeTemplateFromDocument.xml [utf8] (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_makeTemplateFromDocument.xml [utf8] Mon Apr 12 15:59:09 2010
@@ -53,14 +53,27 @@
         </item>
         <item>
             <key> <string>_body</string> </key>
-            <value> <string>portal_preferences = context.portal_preferences\n
+            <value> <string>portal = context.getPortalObject()\n
 \n
-preference = portal_preferences.getActivePreference()\n
-if preference is None or preference.getPreferenceState()!=\'enabled\':\n
-  p = portal_preferences.newContent(portal_type=\'Preference\')\n
+preference = portal.portal_preferences.getActivePreference()\n
+if preference is None\\\n
+    or preference.getPreferenceState() != \'enabled\'\\\n
+    or not portal.portal_membership.checkPermission(\n
+      \'Add portal content\', preference):\n
+  p = portal.portal_preferences.newContent(portal_type=\'Preference\')\n
   p.setTitle(\'Document Template Container\')\n
   p.enable()\n
   preference = p\n
+\n
+\n
+# if the preference already contains a template with the same name, making\n
+# another template will replace it\n
+document_title = context.getTitle()\n
+for existing_template in preference.contentValues(\n
+    portal_type=context.getPortalType()):\n
+  if existing_template.getTitle() == document_title:\n
+    preference.manage_delObjects(ids=[existing_template.getId()])\n
+    break\n
 \n
 parent = context.getParentValue()\n
 document_id = context.getId()\n
@@ -115,14 +128,16 @@
                             <string>kw</string>
                             <string>_getattr_</string>
                             <string>context</string>
-                            <string>portal_preferences</string>
+                            <string>portal</string>
                             <string>preference</string>
                             <string>None</string>
                             <string>p</string>
+                            <string>document_title</string>
+                            <string>_getiter_</string>
+                            <string>existing_template</string>
                             <string>parent</string>
                             <string>document_id</string>
                             <string>cp</string>
-                            <string>_getiter_</string>
                             <string>paste_info</string>
                             <string>getattr</string>
                             <string>_getitem_</string>

Modified: erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision?rev=34467&r1=34466&r2=34467&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision [utf8] (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision [utf8] Mon Apr 12 15:59:09 2010
@@ -1,1 +1,1 @@
-1560
+1561




More information about the Erp5-report mailing list