apps: envoi un mail à l'usager pour tout modification de son compte (#16594)

This commit is contained in:
Benjamin Dauvergne 2017-11-16 11:37:55 +01:00
parent 41057472a5
commit b83866c032
4 changed files with 32 additions and 2 deletions

View File

@ -473,12 +473,22 @@ class AppConfig(django.apps.AppConfig):
actor=actor,
message=message)
def log_modification(self, actor, subject, message):
def log_modification(self, actor, subject, message, mail=True):
from . import models
from authentic2.utils import send_templated_mail
models.Journal.objects.create(
actor=actor,
subject=subject,
message=message)
# pour les modifications sur les usagers on envoie un mail à l'usager
if subject.ou and subject.ou.slug == 'usagers' and mail:
send_templated_mail(subject, 'authentic2/cut-notify-usager-modification',
context={
'message': message,
'usager': subject,
'agent': actor,
})
@property
def redis_client(self):
@ -580,4 +590,4 @@ class AppConfig(django.apps.AppConfig):
self.log_modification(user, instance, msg)
def cut_event_manager_view_user(self, user, instance, **kwargs):
self.log_modification(user, instance, u'fiche consultée')
self.log_modification(user, instance, u'fiche consultée', mail=False)

View File

@ -0,0 +1,12 @@
{% extends "emails/body_base.html" %}
{% block content %}
<p>Bonjour,</p>
<p>
Un agent vient de modifier votre compte de la manière suivante:
</p>
<ul><li>{{ message }}</li></ul>
{% endblock %}

View File

@ -0,0 +1,7 @@
{% extends "emails/body_base.txt" %}
{% block content %}Bonjour,
Un agent vient de modifier votre compte de la manière suivante :
- {{ message }}
{% endblock %}

View File

@ -0,0 +1 @@
{% firstof global_title site_name site "Compte Citoyen" %} : modification de votre compte par un agent