flag pour envoyer les mails
[auf_rh_dae.git] / project / dae / mail.py
1 # encoding: utf-8
2
3 from django.conf import settings
4 from django.core.mail import send_mail
5 from django.core.urlresolvers import reverse
6 from django.contrib.auth.models import Group
7 from project import groups
8
9
10 def send_drh_finalisation_mail(request, dossier):
11 if getattr(settings, 'MAIL_NOTIFICATION_DAE', False) is False:
12 return
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 ])
25 grp_drh = Group.objects.get(name=groups.DRH_NIVEAU_1)
26 recipients = [u.email for u in grp_drh.user_set.filter(is_active=True)]
27 send_mail(subject, message, settings.SERVER_EMAIL, recipients)