Skip to content

Commit

Permalink
Make sure conditions are isolated in if (was working but...)
Browse files Browse the repository at this point in the history
  • Loading branch information
gbastien committed Mar 17, 2021
1 parent 4a70754 commit 3bcb9ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/collective/iconifiedcategory/tests/test_behaviors.py
Expand Up @@ -277,8 +277,11 @@ def test_only_pdf_invariant(self):
view = self.portal.restrictedTraverse('folder_contents')
request['PUBLISHED'] = view
self.assertFalse(invariants.validate(data))
request.set('already_validateFileIsPDF', False)
# already_validateFileIsPDF was set in REQUEST
self.assertTrue(request.get('already_validateFileIsPDF'))
self.assertFalse(invariants.validate(data))
# PDF needed
request.set('already_validateFileIsPDF', False)
category.only_pdf = True
errors = invariants.validate(data)
request.set('already_validateFileIsPDF', False)
Expand Down
4 changes: 2 additions & 2 deletions src/collective/iconifiedcategory/utils.py
Expand Up @@ -298,8 +298,8 @@ def _check_filters(infos):
catalog = api.portal.get_tool('portal_catalog')
current_user_allowedRolesAndUsers = catalog._listAllowedRolesAndUsers(api.user.get_current())
for uid, infos in categorized_elements.items():
if uids and uid not in uids or \
portal_type and infos['portal_type'] != portal_type or \
if (uids and uid not in uids) or \
(portal_type and infos['portal_type'] != portal_type) or \
not _check_filters(infos) or \
(infos['confidential'] and
not set(infos['allowedRolesAndUsers']).intersection(current_user_allowedRolesAndUsers)):
Expand Down

0 comments on commit 3bcb9ee

Please sign in to comment.