Commit e95190ae authored by Aurel's avatar Aurel

do not unindex copy of object when building bt, add test for this

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@12645 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a49997fc
......@@ -435,6 +435,9 @@ class BaseTemplateItem(Implicit, Persistent):
elif getattr(obj, 'meta_type', None) == 'ERP5 PDF Form' :
if not obj.getProperty('business_template_include_content', 1) :
obj.deletePdfContent()
if getattr(aq_base(obj), 'isIndexable', None) == 1:
# prevent from unindexing copy of object
setattr(obj, 'isIndexable', 0)
return obj
class ObjectTemplateItem(BaseTemplateItem):
......@@ -898,6 +901,12 @@ class PathTemplateItem(ObjectTemplateItem):
if len(id_list) > 0:
if include_subobjects:
self.build_sub_objects(context, id_list, relative_url)
else:
for id_ in id_list:
subobj = obj[id_]
if getattr(aq_base(subobj), 'isIndexable', None) == 1:
# prevent from unindexing copy of object
setattr(subobj, 'isIndexable', 0)
for id_ in list(id_list):
obj._delObject(id_)
if hasattr(aq_base(obj), 'groups'):
......@@ -978,6 +987,10 @@ class CategoryTemplateItem(ObjectTemplateItem):
obj._delObject(id_)
else:
for id_ in list(id_list):
subobj = obj[id_]
if getattr(aq_base(subobj), 'isIndexable', None) == 1:
# prevent from unindexing copy of object
setattr(subobj, 'isIndexable', 0)
obj._delObject(id_)
self._objects[relative_url] = obj
obj.wl_clearLocks()
......
......@@ -1910,6 +1910,31 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
if hasattr(aq_base(data), 'uid'):
self.failUnless(data.uid is None)
def stepCheckUnindexActivityPresence(self, sequence=None, sequence_list=None, **kw):
"""
Check if we have activity for unindex
"""
sql_connection = self.getSQLConnection()
sql = "select uid from message_queue where method_id='unindexObject'" # where id='unindexObject'"
r = sql_connection.manage_test(sql)
self.failUnless(len(r) == 0)
def stepCheckPathNotUnindexAfterBuild(self, sequence=None, sequence_list=None, **kw):
"""
Check that after a build, not unindex has been done
"""
bc_id = sequence.get('bc_id')
bt = sequence.get('current_bt')
path = 'portal_categories/'+bc_id
category_id_list = sequence.get('category_id_list')
portal = self.getPortal()
ob = portal.unrestrictedTraverse(path)
self.failUnless(ob is not None)
for id_ in category_id_list:
cat = ob[id_]
catalog_ob_list = [x.getObject() for x in portal.portal_catalog(uid=cat.getUid())]
self.failUnless(len(catalog_ob_list) > 0)
def stepSetUpdateWorkflowFlagInBusinessTemplate(self, sequence=None, sequence_list=None):
"""
Set flag for update in Business Template
......@@ -2469,6 +2494,36 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet)
def test_091_BusinessTemplateDoNotUnindexObject(self, quiet=quiet, run=un_all_test):
if not run: return
if not quiet:
message = 'Test Business Template Do Not Unindex Object At Build'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ', 0, message)
sequence_list = SequenceList()
# a simple path
sequence_string = '\
CreateBaseCategory \
CreateCategories \
CreateNewBusinessTemplate \
Tic \
UseExportBusinessTemplate \
CheckModifiedBuildingState \
CheckNotInstalledInstallationState \
AddBaseCategoryAsPathToBusinessTemplate \
BuildBusinessTemplate \
CheckUnindexActivityPresence \
Tic \
CheckPathNotUnindexAfterBuild \
CheckBuiltBuildingState \
CheckNotInstalledInstallationState \
CheckObjectPropertiesInBusinessTemplate \
RemoveBaseCategory \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet)
def test_10_BusinessTemplateWithPathAndJoker1(self, quiet=quiet, run=run_all_test):
if not run: return
if not quiet:
......@@ -2515,7 +2570,7 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet)
def test_101_BusinessTemplateUninstallWithPathAndJoker1Removed(self, quiet=quiet, run=1): #run_all_test):
def test_101_BusinessTemplateUninstallWithPathAndJoker1Removed(self, quiet=quiet, run=run_all_test):
if not run: return
if not quiet:
message = 'Test Business Template Uninstall With Path And Joker * Removed'
......
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