Skip to content

Commit

Permalink
Merge branch 'fix-email-access-authn' of https://github.com/NCAR/ckan…
Browse files Browse the repository at this point in the history
…ext-harvest into NCAR-fix-email-access-authn
  • Loading branch information
amercader committed Sep 20, 2022
2 parents 98edcd3 + 125ec71 commit 72e9fee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ development.ini
node_modules
*.project
.eggs
.vscode/
.idea/
.vscode/

13 changes: 9 additions & 4 deletions ckanext/harvest/logic/action/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,11 +436,13 @@ def harvest_get_notifications_recipients(context, data_dict):
model.User.sysadmin == True # noqa: E712
).all()

# Send mail to all sysadmins with a non-empty email address
for sysadmin in sysadmins:
if sysadmin.email:
email_address = sysadmin.email
if email_address and email_address.strip():
recipients.append({
'name': sysadmin.name,
'email': sysadmin.email
'email': email_address,
})

# gather organization-admins
Expand All @@ -451,14 +453,17 @@ def harvest_get_notifications_recipients(context, data_dict):
'capacity': 'admin'
})

# Get access to email address by running action as admin user
context['user'] = p.toolkit.get_action('get_site_user')({'ignore_auth': True})['name']
for member in members:
member_details = p.toolkit.get_action(
'user_show')(context, {'id': member[0]})

if member_details.get('email', None):
email_address = member_details.get('email', None)
if email_address and email_address.strip():
recipients.append({
'name': member_details['name'],
'email': member_details['email']
'email': email_address
})

return recipients

0 comments on commit 72e9fee

Please sign in to comment.