From d84c3a689012cac90b92d452ecfdd2b85e0bb99b Mon Sep 17 00:00:00 2001 From: "nilovna.bascunan-vasquez" Date: Wed, 29 Jun 2011 15:34:18 -0400 Subject: [PATCH] Modifications pas bonnes --- project/recrutement/forms.py | 17 ++++++ project/recrutement/models.py | 28 ++++++++-- .../recrutement/envoyer_courriel_candidats.html | 56 ++++++++++++++++++++ project/recrutement/views.py | 19 ++++++- project/urls.py | 3 ++ 5 files changed, 118 insertions(+), 5 deletions(-) create mode 100644 project/recrutement/templates/recrutement/envoyer_courriel_candidats.html diff --git a/project/recrutement/forms.py b/project/recrutement/forms.py index f434ade..92b39db 100644 --- a/project/recrutement/forms.py +++ b/project/recrutement/forms.py @@ -78,3 +78,20 @@ class PostulerOffreEmploiForm(ModelForm): 'telephone', 'email', 'adresse', 'ville', 'code_postal', 'etat_province', 'pays', 'captcha', ) +################################################################################ +# TEMPLATE COURRIEL +################################################################################ +class CandidatCourrielForm(ModelForm): + #texte = forms.CharField(widget=TinyMCE()) + + def __init__(self, *args, **kwargs): + self.candidats = kwargs.pop('candidats') + super(CandidatCourrielForm, self).__init__(*args, **kwargs) + + def save(self): + super(CandidatCourrielForm, self).save() + + class Meta: + model = recr.CandidatCourriel + fields = ('template','titre', 'texte') + diff --git a/project/recrutement/models.py b/project/recrutement/models.py index e53cf3e..51a8f0c 100755 --- a/project/recrutement/models.py +++ b/project/recrutement/models.py @@ -188,13 +188,33 @@ class CandidatEvaluation(models.Model): verbose_name = 'évaluation du candidat' verbose_name_plural = 'évaluations des candidats' -'''class CandidatLettre(models.Model): +### TEMPLATE COURRIEL +TEMPLATE_CHOICES = ( + ('SEL', 'Sélectionné'), + ('REF', 'Refusé'), +) + +class CourrielTemplate(models.Model): + template_name = models.CharField(max_length=100, ) + subject = models.CharField(max_length=100, ) + heading = models.CharField(max_length=100, ) + plain_text = models.TextField() + html = models.TextField(related_name='+') + + def __unicode__(self): + return u'%s' % self.template_name + + class Meta: + ordering = ['template_name',] + +class CandidatCourriel(models.Model): candidat = models.ForeignKey(Candidat, db_column='candidat', - related_name='+',) + related_name='+', ) + template = models.CharField(max_length=4, choices=TEMPLATE_CHOICES, + default='SEL', verbose_name="Modèle de courriel", ) titre = models.CharField(max_length=255, ) - texte = models.TextField(null=True, blank=True) + texte = models.TextField(null=True, blank=True, ) def __unicode__(self): return '%s' % (self.titre) -''' diff --git a/project/recrutement/templates/recrutement/envoyer_courriel_candidats.html b/project/recrutement/templates/recrutement/envoyer_courriel_candidats.html new file mode 100644 index 0000000..357378a --- /dev/null +++ b/project/recrutement/templates/recrutement/envoyer_courriel_candidats.html @@ -0,0 +1,56 @@ +{% extends 'admin/base_site.html' %} +{% load i18n adminmedia form_utils_tags %} + +{% block title %}RH - Recrutement{% endblock %} +{% block titre %}Ressources humaines{% endblock %} +{% block sous_titre %}Envoyer courriel{% endblock %} +{% block extrahead %} + +{{ form.media }} +{% endblock %} +{% block content %} +
+ {% block object-tools %}{% endblock %} + + + +
+

Envoyer un courriel aux candidats

+ +
+ + + + + + + + + + + + + + + + + + + + +
Candidats sélectionnés +
{{ form.template.label }}{{ form.template }}
{{ form.titre.label }}{{ form.titre }}
{{ form.texte.label }}{{ form.texte }}
+
+ +
+
+
+ + +
+ +{% endblock %} diff --git a/project/recrutement/views.py b/project/recrutement/views.py index 35285b8..767e90a 100755 --- a/project/recrutement/views.py +++ b/project/recrutement/views.py @@ -69,6 +69,23 @@ def affecter_evaluateurs_candidats(request): return render_to_response("recrutement/affecter_evaluateurs.html", Context(c), context_instance = RequestContext(request)) +def envoyer_courriel_candidats(request): + candidat_ids = request.GET.get('ids').split(',') + candidats = Candidat.objects.filter(id__in=candidat_ids) + if request.method == "POST": + form = CandidatCourrielForm(request.POST, candidats=candidats) + if form.is_valid(): + form.save() + messages.add_message(request, messages.SUCCESS, + "Les évaluateurs ont été affectés aux candidats.") + return redirect("admin:recrutement_candidat_changelist") + else: + form = CandidatCourrielForm(candidats=candidats) + + c = {'form' : form} + return render_to_response("recrutement/envoyer_courriel_candidats.html", + Context(c), context_instance = RequestContext(request)) + def postuler_appel_offre(request): vars = dict() @@ -99,7 +116,7 @@ def postuler_appel_offre(request): offre_emploi.nom + u" a été effectuée avec succès. Vous\ devriez être contacté sous peu par l'AUF. \n\n Merci \ pour votre intérêt envers l'AUF.", - 'contact@nilovna.com', + 'test@auf.org', [candidat.email], fail_silently=False) return redirect("admin:recrutement_offreemploi_changelist") diff --git a/project/urls.py b/project/urls.py index 674c3c8..55b2560 100644 --- a/project/urls.py +++ b/project/urls.py @@ -22,6 +22,9 @@ urlpatterns = patterns( url(r'^recrutement/affecter_evaluateurs_candidats/$', 'recrutement.views.affecter_evaluateurs_candidats', name='affecter_evaluateurs_candidats'), + url(r'^recrutement/envoyer_courriel_candidats/$', + 'recrutement.views.envoyer_courriel_candidats', + name='envoyer_courriel_candidats'), url(r'^recrutement/afficher_candidat/$', 'recrutement.views.afficher_candidat', name='afficher_candidat'), -- 1.7.10.4