fix for 500 error
[auf_rh_dae.git] / project / dae / mail.py
CommitLineData
0f22933b
EMS
1# encoding: utf-8
2
75f0e87b 3from django.conf import settings
0f22933b
EMS
4from django.core.mail import send_mail
5from django.core.urlresolvers import reverse
3383b2d1
OL
6from django.contrib.auth.models import Group
7from project import groups
0f22933b 8
80b95abf 9
0f22933b 10def send_drh_finalisation_mail(request, dossier):
fb608ac7
OL
11 if getattr(settings, 'MAIL_NOTIFICATION_DAE', False) is False:
12 return
0f22933b
EMS
13 subject = 'DAE: contrat pour %s' % dossier
14 dossier_url = request.build_absolute_uri(
15 reverse('embauche_consulter', kwargs={'dossier_id': dossier.id})
16 )
17 message = '\n'.join([
18 'Le contrat pour la DAE %s a été validé' % dossier,
19 '',
20 'Implantation: %s' % dossier.poste.implantation,
21 'Poste: %s' % dossier.poste,
22 '',
23 dossier_url
24 ])
3383b2d1 25 grp_drh = Group.objects.get(name=groups.DRH_NIVEAU_1)
0f22933b 26 recipients = [u.email for u in grp_drh.user_set.filter(is_active=True)]
80b95abf 27 send_mail(subject, message, settings.SERVER_EMAIL, recipients)