Browse Source

[enh] Use utils.send_templated_email

ljf 6 years ago
parent
commit
b9566cff81
1 changed files with 8 additions and 9 deletions
  1. 8 9
      coin/members/models.py

+ 8 - 9
coin/members/models.py

@@ -68,15 +68,14 @@ def send_registration_notification(sender, user, request=None, **kwargs):
     Send a notification to the admin if a user subscribe
     """
     relative_link = reverse('admin:members_member_change', args=[user.id])
-    abs_link = request.build_absolute_uri(relative_link)
-
-    send_mail('[COIN] Nouvelle inscription',
-              'Bonjour,\n' +
-              '%s s\'est enregistré(e) sur COIN.\n' % user.username +
-              'Lien d\'édition: %s' % abs_link,
-              settings.DEFAULT_FROM_EMAIL,
-              settings.NOTIFICATION_EMAILS,
-              fail_silently=False)
+    edit_link = request.build_absolute_uri(relative_link)
+
+    utils.send_templated_email(
+        to=settings.NOTIFICATION_EMAILS,
+        subject_template='members/emails/new_member_subject.txt',
+        body_template='members/emails/new_member_email.html',
+        context={'member': self, 'edit_link': edit_link},
+        **kwargs)
 
 
 class Member(CoinLdapSyncMixin, AbstractUser):