if form.is_valid():
candidat = form.save()
data = serializers.serialize('json', [candidat,])
+
+ evaluateurs = candidat.offre_emploi.evaluateurs.all()
+ for evaluateur in evaluateurs:
+ candidat_evaluation = CandidatEvaluation()
+ candidat_evaluation.candidat = candidat
+ candidat_evaluation.evaluateur = evaluateur
+ candidat_evaluation.save()
+
+ courriel_template = CourrielTemplate.objects.get(id=1)
+ send_templated_email(candidat, courriel_template)
return api_return(STATUS_OK, data)
else:
return api_return(STATUS_ERROR, form.errors)
- # evaluateurs = candidat.offre_emploi.evaluateurs.all()
- # for evaluateur in evaluateurs:
- # candidat_evaluation = CandidatEvaluation()
- # candidat_evaluation.candidat = candidat
- # candidat_evaluation.evaluateur = evaluateur
- # candidat_evaluation.save()
-
- # try:
- # courriel_template = CourrielTemplate.objects.get(id=1)
- # send_templated_email(candidat, courriel_template)
- # except:
- # return api_return(STATUS_OK, simplejson.dumps(
- # {'candidat_id': candidat.id}), json=True)
- #except:
- # return api_return(STATUS_ERROR)
def api_offre_emploi_liste(self):
# -*- encoding: utf-8 -*-
-from django.contrib import messages
-from django.contrib.auth.models import User
from django.core.mail import send_mail
from django.core.urlresolvers import reverse
+from django.contrib import messages
+from django.contrib.auth.models import User
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render_to_response, redirect, get_object_or_404
from django.template import Context, RequestContext, Template
Context(c), context_instance = RequestContext(request))
def send_templated_email(candidat, template):
+ from django.conf import settings
# Sujet
sujet_template = Template(template.sujet)
dict_sujet = {"offre_emploi": candidat.offre_emploi.nom,}
# HTML text
html_template = Template(template.html)
texte_html = Context(dict_texte)
+ if settings.DEBUG:
+ dst_emails = ['developpeurs@ca.auf.org', ]
+ else:
+ dst_emails = [candidat.email, ]
msg = EmailMultiAlternatives(sujet_template.render(sujet),
texte_template.render(texte),
'recrutement@auf.org',
- [candidat.email])
+ dst_emails,
+ )
msg.attach_alternative(texte_template.render(texte_html), "text/html")
msg.send()
'paste_remove_styles' : 'true',
'content_css' : '/media/css/tinymce.css',
}
-
-EMAIL_HOST = 'localhost'
-EMAIL_PORT = '1025'
-
-#FILE_PROTECTION_METHOD = 'basic'