send harvest-error-mails to organization-admins
This commit is contained in:
parent
7dd82a0e01
commit
304bbcec06
|
@ -186,11 +186,11 @@ If you don't specify this setting, the default will be number-sequence.
|
||||||
Send error mails when harvesting fails (optional)
|
Send error mails when harvesting fails (optional)
|
||||||
=================================================
|
=================================================
|
||||||
|
|
||||||
If you want to send and email when a Harvest Job fails, you can set the following configuration option in the ini file:
|
If you want to send an email when a Harvest Job fails, you can set the following configuration option in the ini file:
|
||||||
|
|
||||||
ckan.harvest.status_mail.errored = True
|
ckan.harvest.status_mail.errored = True
|
||||||
|
|
||||||
That way, all CKAN Users who are declared as Sysadmins will receive the Error emails at their configured email address.
|
That way, all CKAN Users who are declared as Sysadmins will receive the Error emails at their configured email address. If the Harvest-Source of the failing Harvest-Job belongs to an organization, the error-mail will also be sent to the organization-members who have the admin-role if their E-Mail is configured.
|
||||||
|
|
||||||
If you don't specify this setting, the default will be False.
|
If you don't specify this setting, the default will be False.
|
||||||
|
|
||||||
|
|
|
@ -621,14 +621,35 @@ def send_error_mail(context, source_id, status):
|
||||||
msg += '\n--\n'
|
msg += '\n--\n'
|
||||||
msg += toolkit._('You are receiving this email because you are currently set-up as Administrator for {0}. Please do not reply to this email as it was sent from a non-monitored address.').format(config.get('ckan.site_title'))
|
msg += toolkit._('You are receiving this email because you are currently set-up as Administrator for {0}. Please do not reply to this email as it was sent from a non-monitored address.').format(config.get('ckan.site_title'))
|
||||||
|
|
||||||
|
recipients = []
|
||||||
|
|
||||||
|
# gather sysadmins
|
||||||
model = context['model']
|
model = context['model']
|
||||||
|
|
||||||
sysadmins = model.Session.query(model.User).filter(model.User.sysadmin == True).all()
|
sysadmins = model.Session.query(model.User).filter(model.User.sysadmin == True).all()
|
||||||
|
for sysadmin in sysadmins:
|
||||||
|
recipients.append({
|
||||||
|
'name': sysadmin.name,
|
||||||
|
'email': sysadmin.email
|
||||||
|
})
|
||||||
|
|
||||||
# for recipient in email_recipients:
|
# gather organization-admins
|
||||||
for recipient in sysadmins:
|
if source.get('organization'):
|
||||||
email = {'recipient_name': recipient,
|
members = get_action('member_list')(context, {
|
||||||
'recipient_email': recipient,
|
'id': source['organization']['id'],
|
||||||
|
'object_type': 'user',
|
||||||
|
'capacity': 'admin'
|
||||||
|
})
|
||||||
|
for member in members:
|
||||||
|
member_details = get_action('user_show')(context, {'id': member[0]})
|
||||||
|
if member_details['email']:
|
||||||
|
recipients.append({
|
||||||
|
'name': member_details['name'],
|
||||||
|
'email': member_details['email']
|
||||||
|
})
|
||||||
|
|
||||||
|
for recipient in recipients:
|
||||||
|
email = {'recipient_name': recipient['name'],
|
||||||
|
'recipient_email': recipient['email'],
|
||||||
'subject': config.get('ckan.site_title') + ' - Harvesting Job - Error Notification',
|
'subject': config.get('ckan.site_title') + ' - Harvesting Job - Error Notification',
|
||||||
'body': msg}
|
'body': msg}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue