products/CPSSubscriptions
changeset 1076:b72ee2dec53e CPS-3.5
#2464: mailing list for all auth users and anonymous
author | Georges Racinet on purity.racinet.fr <georges@racinet.fr> |
---|---|
date | Mon, 17 Oct 2011 13:06:26 +0200 |
parents | 652306aaa0b8 |
children | deb568c9e36a |
files | CHANGES RecipientsRules.py SubscriptionsTool.py tests/testRecipientsRules.py |
diffstat | 4 files changed, 34 insertions(+), 11 deletions(-) [+] |
line diff
1.1 --- a/CHANGES 1.2 +++ b/CHANGES 1.3 @@ -6,6 +6,7 @@ 1.4 - 1.5 Bug fixes 1.6 ~~~~~~~~~ 1.7 +- #2464: mailing list for all auth users and anonymous 1.8 - #2049: detailed subscriptions summary 1.9 New internal features 1.10 ~~~~~~~~~~~~~~~~~~~~~
2.1 --- a/RecipientsRules.py 2.2 +++ b/RecipientsRules.py 2.3 @@ -80,14 +80,16 @@ 2.4 layer 2.5 """ 2.6 # pseudo groups special cases 2.7 - if group_id == 'role:Authenticated': 2.8 - email = acl_users.email_for_authenticated 2.9 + 2.10 + def validate(email): 2.11 if not email: 2.12 raise KeyError(group_id) 2.13 + return email 2.14 + 2.15 + if group_id == 'role:Authenticated': 2.16 + return validate(acl_users.email_for_authenticated) 2.17 elif group_id == 'role:Anonymous': 2.18 - email = acl_users.email_for_anonymous 2.19 - if not email: 2.20 - raise KeyError(group_id) 2.21 + return validatel(acl_users.email_for_anonymous) 2.22 elif group_id.startswith('role:'): 2.23 raise KeyError(group_id) 2.24
3.1 --- a/SubscriptionsTool.py 3.2 +++ b/SubscriptionsTool.py 3.3 @@ -980,6 +980,7 @@ 3.4 aclu = getToolByName(self, 'acl_users') 3.5 utool = getToolByName(self, 'portal_url') 3.6 dtool = getToolByName(self, 'portal_directories') 3.7 + cpsmcat = getToolByName(self, 'translation_service') 3.8 base_url = utool.getBaseUrl() 3.9 3.10 def record(category, recipient, event): 3.11 @@ -993,15 +994,17 @@ 3.12 if rec_dict is None: 3.13 category[recipient] = rec_dict = dict(id=recipient, events=[]) 3.14 3.15 + dir_attr = None 3.16 if category is members: 3.17 - attr = 'users_dir' 3.18 + dir_attr = 'users_dir' 3.19 elif category is groups: 3.20 - attr = 'groups_dir' 3.21 - else: 3.22 - attr = None 3.23 + if recipient.startswith('role:'): 3.24 + rec_dict['title'] = cpsmcat(recipient) 3.25 + else: 3.26 + dir_attr = 'groups_dir' 3.27 3.28 - if attr: 3.29 - dirname = getattr(aclu, attr) 3.30 + if dir_attr: 3.31 + dirname = getattr(aclu, dir_attr) 3.32 dirobj = dtool[dirname] 3.33 try: 3.34 entry = dirobj.getEntry(recipient)
4.1 --- a/tests/testRecipientsRules.py 4.2 +++ b/tests/testRecipientsRules.py 4.3 @@ -559,6 +559,23 @@ 4.4 }.get 4.5 4.6 4.7 + # role:authenticated 4.8 + rrr.acl_users.email_for_authenticated = 'all@cps.example' 4.9 + 4.10 + rrr.portal_membership.getMergedLocalRoles = lambda _: { 4.11 + 'group:role:Authenticated': ('FakeRole',), 4.12 + } 4.13 + recipients = rrr.getRecipients('fake_event', container, infos={}, 4.14 + expand_groups=False) 4.15 + self.assertEquals(recipients, 4.16 + ({}, {'all@cps.example': 'role:Authenticated'})) 4.17 + 4.18 + # Again with no address specified 4.19 + rrr.acl_users.email_for_authenticated = '' 4.20 + recipients = rrr.getRecipients('fake_event', container, infos={}, 4.21 + expand_groups=False) 4.22 + self.assertEquals(recipients, ({}, {})) 4.23 + 4.24 # Just the user 4.25 rrr.portal_membership.getMergedLocalRoles = lambda _: { 4.26 'user:manager': ('FakeRole',),