From 5ffc0edae7f0b0f9a0d1bf3059eb23a06d22aa83 Mon Sep 17 00:00:00 2001
From: Nicolas Delaby <nicolas@nexedi.com>
Date: Thu, 18 Feb 2010 10:01:24 +0000
Subject: [PATCH] Avoid clearing activities if portal_actvities already exists.
 This is the responsability of site Manager to recreate Activity SQL Table if
 their structure change. Reviewed by Aurel

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32743 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/BusinessTemplate.py | 8 ++++++--
 product/ERP5/ERP5Site.py                  | 6 +++---
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/product/ERP5/Document/BusinessTemplate.py b/product/ERP5/Document/BusinessTemplate.py
index 14e83fc5d5..a5c6aa88e8 100644
--- a/product/ERP5/Document/BusinessTemplate.py
+++ b/product/ERP5/Document/BusinessTemplate.py
@@ -5179,8 +5179,12 @@ Business Template is a set of definitions, such as skins, portal types and categ
       gen = generator_class()
       # update activity tool first if necessary
       if self.getTitle() == 'erp5_core' and self.getTemplateUpdateTool():
-        LOG('Business Template', 0, 'Updating Activity Tool')
-        gen.setupLastTools(site, update=1, create_activities=1)
+        if not site.hasObject('portal_activities'):
+          create_activities = True
+          LOG('Business Template', 0, 'Updating Activity Tool')
+        else:
+          create_activities = False
+        gen.setupLastTools(site, update=1, create_activities=create_activities)
       if not force:
         if len(object_to_update) == 0:
           # check if we have to update tools
diff --git a/product/ERP5/ERP5Site.py b/product/ERP5/ERP5Site.py
index e9923c6329..6b4c034edc 100644
--- a/product/ERP5/ERP5Site.py
+++ b/product/ERP5/ERP5Site.py
@@ -62,7 +62,7 @@ def manage_addERP5Site(self,
                        title='ERP5',
                        description='',
                        create_userfolder=1,
-                       create_activities=1,
+                       create_activities=True,
                        email_from_address='postmaster@localhost',
                        email_from_name='Portal Administrator',
                        validate_email=0,
@@ -1432,7 +1432,7 @@ class ERP5Generator(PortalGenerator):
              erp5_sql_deferred_connection_type,
              cmf_activity_sql_connection_type,
              cmf_activity_sql_connection_string,
-             create_activities=1,
+             create_activities=True,
              reindex=1,
              **kw):
     id = str(id)
@@ -1471,7 +1471,7 @@ class ERP5Generator(PortalGenerator):
     make sure that we do not put un the queue the full reindexation
     """
     # Add Activity Tool
-    if kw.has_key('create_activities') and int(kw['create_activities'])==1:
+    if kw.get('create_activities', False):
       if not p.hasObject('portal_activities'):
         addTool = p.manage_addProduct['CMFActivity'].manage_addTool
         addTool('CMF Activity Tool', None) # Allow user to select active/passive
-- 
2.30.9