Commit 50de126f authored by Vitalis Salis's avatar Vitalis Salis

astakos: On project approve email the admins

When a project is approved send an email
to the admins specified by a setting on
astakos.
parent 4b867a1e
......@@ -993,6 +993,7 @@ def approve_application(application_id, project_id=None, request_user=None,
application = get_application(application_id)
check_app_relevant(application, project, project_id)
app_check_allowed(application, request_user, level=ADMIN_LEVEL)
previous_state = project.state_display()
if not application.can_approve():
m = _(astakos_messages.APPLICATION_CANNOT_APPROVE %
......@@ -1014,6 +1015,8 @@ def approve_application(application_id, project_id=None, request_user=None,
quotas.qh_sync_project(project)
if QUOTA_POLICY:
QUOTA_POLICY.check_state_projects([project], 'MODIFY')
project_notif.application_approved_admins_notify(application, previous_state)
logger.info("%s has been approved." % (application.log_display))
project_notif.application_notify(application, "approve")
return project
......
......@@ -343,6 +343,7 @@ HELPDESK_NOTIFICATION_EMAIL_SUBJECT = \
'%s account activated (%%(user)s)' % _SITENAME
EMAIL_CHANGE_NEW_EMAIL_SUBJECT = '%s e-mail change notification' % _SITENAME
EMAIL_CHANGE_OLD_EMAIL_SUBJECT = '%s e-mail change notification' % _SITENAME
EMAIL_ADMIN_APPLICATION_APPROVED = "%s project application approved ({0})" % _SITENAME
PASSWORD_RESET_EMAIL_SUBJECT = 'Password reset on %s' % _SITENAME
PROJECT_CREATION_SUBJECT = \
'%s application for a new project created (%%s)' % _SITENAME
......
......@@ -146,3 +146,30 @@ def project_notify(project, action):
).send()
except NotificationError, e:
logger.error(e.message)
APPLICATION_APPROVED_NOTIF = {
'subject': _(messages.EMAIL_ADMIN_APPLICATION_APPROVED),
'template': 'im/application_approved_admin_email.txt',
}
def application_approved_admins_notify(application, previous_state):
recipients = []
for name, mail in list(settings.PROJECT_NOTIFICATIONS_RECIPIENTS):
recipients.append(mail)
try:
notification = build_notification(
SENDER,
recipients,
APPLICATION_APPROVED_NOTIF['subject'].format(application.chain.name),
template=APPLICATION_APPROVED_NOTIF['template'],
dictionary={
'application': application,
'previous_state': previous_state
}
)
notification.send()
except NotificationError, e:
logger.error(e.message)
{% extends "im/email.txt" %}
{% load filters %}
{% block content %}
The following application for a(n) {{ previous_state }} project has been approved by {{ application.response_actor }}:
Id: {{ application.id }}
Project: {{ application.chain.uuid }}
Applicant: {{ application.applicant }}
Issue date: {{ application.issue_date|date:"d/m/Y" }}
Name: {{ application.name|default_if_none:"[no change]" }}
Owner: {{ application.owner|default_if_none:"[no change]" }}
Start date: {% if application.start_date %}{{ application.start_date|date:"d/m/Y" }}{% else %}[no change]{% endif %}
End date: {% if application.end_date %}{{ application.end_date|date:"d/m/Y" }}{% else %}[no change]{% endif %}
Member Join Policy: {{ application.member_join_policy_display|default_if_none:"[no change]" }}
Member Leave Policy: {{ application.member_leave_policy_display|default_if_none:"[no change]" }}
Max members: {{ application.limit_on_members_number|format_inf }}
Quota limits:
{% for rp in application.projectresourcegrant_set.all %}
{{ rp }}
{% empty %}
[no change]
{% endfor %}
{% endblock content %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment