products/CPSSubscriptions

changeset 1091:5afca00bc27d CPS-3.5

#2568: Filtering by groups in manual notification users search
author Georges Racinet on purity.racinet.fr <georges@racinet.fr>
date Tue, 18 Sep 2012 15:37:01 +0200
parents 9cd1f6311d1d
children 9c9ad51dd327
files CHANGES skins/cps_subscriptions/content_notify_email_do_search_results.py
diffstat 2 files changed, 16 insertions(+), 5 deletions(-) [+]
line diff
     1.1 --- a/CHANGES
     1.2 +++ b/CHANGES
     1.3 @@ -6,7 +6,7 @@
     1.4  -
     1.5  Bug fixes
     1.6  ~~~~~~~~~
     1.7 --
     1.8 +- #2568: Filtering by groups in manual notification users search
     1.9  New internal features
    1.10  ~~~~~~~~~~~~~~~~~~~~~
    1.11  - 
     2.1 --- a/skins/cps_subscriptions/content_notify_email_do_search_results.py
     2.2 +++ b/skins/cps_subscriptions/content_notify_email_do_search_results.py
     2.3 @@ -1,5 +1,8 @@
     2.4  ##parameters=dir, datastructure, **kw
     2.5  
     2.6 +import logging
     2.7 +logger = logging.getLogger('Products.CPSSubscriptions.notify')
     2.8 +
     2.9  datamodel = datastructure.getDataModel()
    2.10  
    2.11  original_mapping = {}
    2.12 @@ -35,27 +38,35 @@
    2.13      dict_roles = mtool.getMergedLocalRoles(call_context, withgroups=0)
    2.14      search_restricted_list = dict_roles.keys()
    2.15      users_mapping[dir.id_field] = search_restricted_list
    2.16 +
    2.17 +logger.info("users_mapping %r", users_mapping)
    2.18  results = dir.searchEntries(return_fields=return_fields, **users_mapping)
    2.19 +logger.info("results %r", results)
    2.20 +
    2.21  
    2.22  #
    2.23  # Check if there's groups with local roles
    2.24  #
    2.25  
    2.26  dict_roles = mtool.getMergedLocalRoles(call_context, withgroups=1)
    2.27 -groups = [x[len('group:'):] for x in dict_roles if x.startswith('group:')]
    2.28 +groups_with_roles = [x[len('group:'):] for x in dict_roles if x.startswith('group:')]
    2.29  
    2.30  # special handling of special groups to behave as the RecipientRules logic
    2.31 -if "role:Authenticated" in groups and not aclu.is_role_authenticated_empty:
    2.32 +if "role:Authenticated" in groups_with_roles and not aclu.is_role_authenticated_empty:
    2.33      results = dir.searchEntries(return_fields=return_fields, **original_mapping)
    2.34      skip_groups = True
    2.35 -elif "role:Anonymous" in groups and not aclu.is_role_anonymous_empty:
    2.36 +elif "role:Anonymous" in groups_with_roles and not aclu.is_role_anonymous_empty:
    2.37      results = dir.searchEntries(return_fields=return_fields, **original_mapping)
    2.38      skip_groups = True
    2.39  else:
    2.40      skip_groups = False
    2.41  
    2.42 +# GR there are problems with sets in skin scripts
    2.43 +wanted_groups = original_mapping.get('groups', ())
    2.44  if not skip_groups:
    2.45 -    for group_id  in groups:
    2.46 +    for group_id in groups_with_roles:
    2.47 +        if not group_id in wanted_groups:
    2.48 +            continue
    2.49          group_mapping = original_mapping.copy()
    2.50          group_mapping['groups'] = [group_id]
    2.51          group_member_results = dir.searchEntries(return_fields=return_fields,