products/CPSSubscriptions

changeset 1085:588331c36d9f

Merge from 3.5 branch
author Georges Racinet on ishtar.racinet.fr <georges@racinet.fr>
date Sat, 31 Dec 2011 18:22:01 +0100
parents 8362848aabdd 9cd1f6311d1d
children 2782ac32ddda
files SubscriptionsTool.py
diffstat 7 files changed, 79 insertions(+), 10 deletions(-) [+]
line diff
     1.1 --- a/.hgtags
     1.2 +++ b/.hgtags
     1.3 @@ -75,3 +75,4 @@
     1.4  d0062e5d9edd9bc6c842cd6c67bf56832a79ad4f 0.0.1
     1.5  41600f91aaa0cfb21f4469ed101f016bbd3d715f 1.3.2
     1.6  0b34cc150e1b675349cd255771c49240ac96c97a 1.4.0-CPS-3.5
     1.7 +adfd807f4dbddf589fde8b097d1693db1c9d6509 1.4.1-CPS-3.5
     2.1 --- a/CHANGES
     2.2 +++ b/CHANGES
     2.3 @@ -6,7 +6,7 @@
     2.4  -
     2.5  Bug fixes
     2.6  ~~~~~~~~~
     2.7 -- #2049: detailed subscriptions summary
     2.8 +-
     2.9  New internal features
    2.10  ~~~~~~~~~~~~~~~~~~~~~
    2.11  - 
     3.1 --- a/HISTORY
     3.2 +++ b/HISTORY
     3.3 @@ -1,3 +1,21 @@
     3.4 +===========================================================
     3.5 +Package: CPSSubscriptions 1.4.1-CPS-3.5
     3.6 +===========================================================
     3.7 +First release built by: gracinet at: 2011-11-23T19:59:06
     3.8 +Requires
     3.9 +~~~~~~~~
    3.10 +-
    3.11 +New features
    3.12 +~~~~~~~~~~~~
    3.13 +-
    3.14 +Bug fixes
    3.15 +~~~~~~~~~
    3.16 +- #2464: mailing list for all auth users and anonymous
    3.17 +- #2049: detailed subscriptions summary
    3.18 +New internal features
    3.19 +~~~~~~~~~~~~~~~~~~~~~
    3.20 +- 
    3.21 +
    3.22  ===========================================================
    3.23  Package: CPSSubscriptions 1.4.0-CPS-3.5
    3.24  ===========================================================
     4.1 --- a/RecipientsRules.py
     4.2 +++ b/RecipientsRules.py
     4.3 @@ -79,6 +79,20 @@
     4.4          Note: Group object in CPSUserFolder is presented as a minimal compat
     4.5          layer
     4.6          """
     4.7 +        # pseudo groups special cases
     4.8 +
     4.9 +        def validate(email):
    4.10 +            if not email:
    4.11 +                raise KeyError(group_id)
    4.12 +            return email
    4.13 +
    4.14 +        if group_id == 'role:Authenticated':
    4.15 +            return validate(acl_users.email_for_authenticated)
    4.16 +        elif group_id == 'role:Anonymous':
    4.17 +            return validate(acl_users.email_for_anonymous)
    4.18 +        elif group_id.startswith('role:'):
    4.19 +            raise KeyError(group_id)
    4.20 +
    4.21          email_field = acl_users.groups_email_field
    4.22          if not email_field:
    4.23              logger.error("Email field for groups not configured."
    4.24 @@ -857,8 +871,7 @@
    4.25  
    4.26          Takes all little detail, like 'role:' pseudo groups into account.
    4.27          """
    4.28 -
    4.29 -        if group_id.startswith('role:'):
    4.30 +        if group_id.startswith('role:') and expand_groups:
    4.31              return # TODO apply a few mailing lists or what
    4.32  
    4.33          if not expand_groups:
     5.1 --- a/SubscriptionsTool.py
     5.2 +++ b/SubscriptionsTool.py
     5.3 @@ -980,6 +980,7 @@
     5.4          aclu = getToolByName(self, 'acl_users')
     5.5          utool = getToolByName(self, 'portal_url')
     5.6          dtool = getToolByName(self, 'portal_directories')
     5.7 +        cpsmcat = getToolByName(self, 'translation_service')
     5.8          base_url = utool.getBaseUrl()
     5.9  
    5.10          def record(category, recipient, event):
    5.11 @@ -993,15 +994,17 @@
    5.12              if rec_dict is None:
    5.13                  category[recipient] = rec_dict = dict(id=recipient, events=[])
    5.14  
    5.15 +                dir_attr = None
    5.16                  if category is members:
    5.17 -                    attr = 'users_dir'
    5.18 +                    dir_attr = 'users_dir'
    5.19                  elif category is groups:
    5.20 -                    attr = 'groups_dir'
    5.21 -                else:
    5.22 -                    attr = None
    5.23 +                    if recipient.startswith('role:'):
    5.24 +                        rec_dict['title'] = cpsmcat(recipient)
    5.25 +                    else:
    5.26 +                        dir_attr = 'groups_dir'
    5.27  
    5.28 -                if attr:
    5.29 -                    dirname = getattr(aclu, attr)
    5.30 +                if dir_attr:
    5.31 +                    dirname = getattr(aclu, dir_attr)
    5.32                      dirobj = dtool[dirname]
    5.33                      try:
    5.34                          entry = dirobj.getEntry(recipient)
     6.1 --- a/VERSION
     6.2 +++ b/VERSION
     6.3 @@ -1,5 +1,5 @@
     6.4  #BUNDLEMAN PRODUCT CONFIGURATION FILE
     6.5  # do not edit this file
     6.6  PKG_NAME=CPSSubscriptions
     6.7 -PKG_VERSION=1.4.0-CPS-3.5
     6.8 +PKG_VERSION=1.4.1-CPS-3.5
     6.9  PKG_RELEASE=1
     7.1 --- a/tests/testRecipientsRules.py
     7.2 +++ b/tests/testRecipientsRules.py
     7.3 @@ -559,6 +559,40 @@
     7.4          }.get
     7.5  
     7.6  
     7.7 +        # role:authenticated
     7.8 +        rrr.acl_users.email_for_authenticated = 'all@cps.example'
     7.9 +
    7.10 +        rrr.portal_membership.getMergedLocalRoles = lambda _: {
    7.11 +            'group:role:Authenticated': ('FakeRole',),
    7.12 +        }
    7.13 +        recipients = rrr.getRecipients('fake_event', container, infos={},
    7.14 +                                       expand_groups=False)
    7.15 +        self.assertEquals(recipients,
    7.16 +                          ({}, {'all@cps.example': 'role:Authenticated'}))
    7.17 +
    7.18 +        # Again with no address specified
    7.19 +        rrr.acl_users.email_for_authenticated = ''
    7.20 +        recipients = rrr.getRecipients('fake_event', container, infos={},
    7.21 +                                       expand_groups=False)
    7.22 +        self.assertEquals(recipients, ({}, {}))
    7.23 +
    7.24 +        # role:anoymous
    7.25 +        rrr.acl_users.email_for_anonymous = 'anon@cps.example'
    7.26 +
    7.27 +        rrr.portal_membership.getMergedLocalRoles = lambda _: {
    7.28 +            'group:role:Anonymous': ('FakeRole',),
    7.29 +        }
    7.30 +        recipients = rrr.getRecipients('fake_event', container, infos={},
    7.31 +                                       expand_groups=False)
    7.32 +        self.assertEquals(recipients,
    7.33 +                          ({}, {'anon@cps.example': 'role:Anonymous'}))
    7.34 +
    7.35 +        # Again with no address specified
    7.36 +        rrr.acl_users.email_for_anonymous = ''
    7.37 +        recipients = rrr.getRecipients('fake_event', container, infos={},
    7.38 +                                       expand_groups=False)
    7.39 +        self.assertEquals(recipients, ({}, {}))
    7.40 +
    7.41          # Just the user
    7.42          rrr.portal_membership.getMergedLocalRoles = lambda _: {
    7.43              'user:manager': ('FakeRole',),