Commit 339883d9 authored by jocelyn's avatar jocelyn
Browse files

Sends a confirmation email to the contributor

Containing the secret contrib management link

fix #45
parent 868e62db
[wifi-with-me] votre demande, {{ contrib.name }}
\ No newline at end of file
Chèr·e {{ contrib.name }},
Ta demande a bien été enregistrée. Elle est en ligne publiquement à l'adresse : <{{ permalink }}>.
Si tout ou partie des informations n'apparaissent pas, c'est que tu as choisi qu'elles ne soient pas publiques.
Tu peux gérer ou supprimer ta demande grace à ce lien privé à conserver :
<{{ management_link }}>
Bien à toi,
Wifi-with-me
......@@ -151,6 +151,24 @@ class TestViews(APITestCase):
self.assertEqual(len(mail.outbox), 1)
self.assertIn('JohnCleese', mail.outbox[0].subject)
self.assertIn('JohnCleese', mail.outbox[0].body)
self.assertEqual(mail.outbox[0].recipients(), ['foo@example.com'])
def test_add_contrib_sends_no_author_email(self):
# Send no email if author did not mentioned an email
post_data = self.mk_contrib_post_data()
del post_data['email']
response = self.client.post('/map/contribute', post_data)
self.assertEqual(response.status_code, 302)
self.assertEqual(len(mail.outbox), 0)
def test_add_contrib_sends_author_email(self):
# Send no email if author did not mentioned an email
response = self.client.post(
'/map/contribute',
self.mk_contrib_post_data(email='author@example.com'))
self.assertEqual(response.status_code, 302)
self.assertEqual(len(mail.outbox), 1)
class TestManageView(APITestCase):
......
......@@ -53,6 +53,20 @@ def add_contrib(request):
settings.NOTIFICATION_EMAILS,
)
# Notification email to the author
if contrib.email:
author_subject = get_template(
'contribmap/mails/new_contrib_author_notice.subject')
author_body = get_template(
'contribmap/mails/new_contrib_author_notice.txt')
send_mail(
author_subject.render(context),
author_body.render(context),
settings.DEFAULT_FROM_EMAIL,
[contrib.email],
)
return redirect(reverse('thanks', kwargs={
'token': mgmt_token,
}))
......
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