Skip to content

Commit

Permalink
Merge pull request #57 from plone/cmfplone-issue-1040
Browse files Browse the repository at this point in the history
In tests, use 'selection.any' in querystrings.
  • Loading branch information
gforcada committed Nov 25, 2015
2 parents b93fdf7 + bc73cd3 commit a40b003
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 16 deletions.
15 changes: 13 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,19 @@ New:

Fixes:

- Add upgrade step to replace selection.is with selection.any operations in
querystrings also for objects using the Collection behavior.
- Again upgrade collections with ``selection.is`` to
``selection.any``, because the standard events and news collections
may have been wrongly created in a new site.
Issue https://github.com/plone/Products.CMFPlone/issues/1040
[maurits]

- In tests, use ``selection.any`` in querystrings.
Issue https://github.com/plone/Products.CMFPlone/issues/1040
[maurits]

- Added upgrade step to replace ``selection.is`` with
``selection.any`` operations in querystrings also for objects using
the Collection behavior.
[thet]


Expand Down
10 changes: 5 additions & 5 deletions plone/app/querystring/tests/testQueryBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def testMakeQueryWithSubject(self):
self.testpage.reindexObject()
query = [{
'i': 'Subject',
'o': 'plone.app.querystring.operation.selection.is',
'o': 'plone.app.querystring.operation.selection.any',
'v': 'Lorem',
}]
results = self.querybuilder._makequery(query=query)
Expand All @@ -88,7 +88,7 @@ def testMakeQueryWithMultipleSubject(self):
self.testpage.reindexObject()
query = [{
'i': 'Subject',
'o': 'plone.app.querystring.operation.selection.is',
'o': 'plone.app.querystring.operation.selection.any',
'v': ['Lorem', 'Ipsum'],
}]
results = self.querybuilder._makequery(query=query)
Expand All @@ -102,7 +102,7 @@ def testMakeQueryWithSubjectWithSpecialCharacters(self):
self.testpage.reindexObject()
query = [{
'i': 'Subject',
'o': 'plone.app.querystring.operation.selection.is',
'o': 'plone.app.querystring.operation.selection.any',
'v': 'Äüö',
}]
results = self.querybuilder._makequery(query=query)
Expand All @@ -119,7 +119,7 @@ def testMakeQueryWithUnicodeSubjectWithSpecialCharacters(self):
self.testpage.reindexObject()
query = [{
'i': 'Subject',
'o': 'plone.app.querystring.operation.selection.is',
'o': 'plone.app.querystring.operation.selection.any',
'v': u'Äüö',
}]
results = self.querybuilder._makequery(query=query)
Expand All @@ -136,7 +136,7 @@ def testMakeQueryWithUnicodeSubjectWithMultipleSubjects(self):
self.testpage.reindexObject()
query = [{
'i': 'Subject',
'o': 'plone.app.querystring.operation.selection.is',
'o': 'plone.app.querystring.operation.selection.any',
'v': [u'Äüö', u'Üöß'],
}]
results = self.querybuilder._makequery(query=query)
Expand Down
7 changes: 4 additions & 3 deletions plone/app/querystring/upgrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ def upgrade_1_to_2_typo_in_registry(context):
registry[name] = values


def fix_select_all_existing_collections(
context,
query={"portal_type": "Collection"}):
def fix_select_all_existing_collections(context, query=None):

if query is None:
query = {"portal_type": "Collection"}

indexes_to_fix = [
u'portal_type',
Expand Down
19 changes: 13 additions & 6 deletions plone/app/querystring/upgrades.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,20 @@
handler=".upgrades.fix_select_all_existing_collections"
/>

<genericsetup:upgradeStep
<genericsetup:upgradeSteps
source="12"
destination="13"
title="Fix ISyndicatableCollection objects"
profile="plone.app.querystring:default"
description="Fix indexes on Dexterity objects by changing 'is' operators to 'any'. All objects using the Collection behavior are fixed."
handler=".upgrades.fix_select_all_syndicatable_collections"
/>
profile="plone.app.querystring:default">
<genericsetup:upgradeStep
title="Fix ISyndicatableCollection objects"
description="Fix indexes on Dexterity objects by changing 'is' operators to 'any'. All objects using the Collection behavior are fixed."
handler=".upgrades.fix_select_all_syndicatable_collections"
/>
<genericsetup:upgradeStep
title="Fix existing collections"
description="Fix indexes on existing collections by changing 'is' operators to 'any'"
handler=".upgrades.fix_select_all_existing_collections"
/>
</genericsetup:upgradeSteps>

</configure>

0 comments on commit a40b003

Please sign in to comment.