1593: Ajouter les pièces jointes pour la postulation.
[auf_rh_dae.git] / project / recrutement / views.py
CommitLineData
6f2d5d58 1# -*- encoding: utf-8 -*-
2from django.shortcuts import redirect, render_to_response, get_object_or_404
362a3534 3from django.http import HttpResponse
4from django.contrib import messages
5from django.template import Context, RequestContext
6from django.shortcuts import render_to_response, redirect
6f2d5d58 7from django.template import RequestContext
8
362a3534 9from forms import *
10from models import *
6f2d5d58 11from project.recrutement import models as recr
12
13def index(request):
362a3534 14 return render_to_response('recrutement/index.html', {},
15 RequestContext(request))
16
596fe324 17def evaluer_candidat(request):
18 candidat = get_object_or_404(Candidat, id__in=request.GET.get('id'))
19
20 if request.method == "POST":
21 candidat_evaluation = CandidatEvaluation()
22 candidat_evaluation.candidat = candidat
8ea41642 23 form = CandidatEvaluationForm(request.POST,
24 instance=candidat_evaluation, candidat=candidat)
596fe324 25 if form.is_valid():
26 form.save()
27 messages.add_message(request, messages.SUCCESS,
28 "Le commentaire et la note ont été affectés \
29 au candidat.")
30 return redirect("admin:recrutement_candidat_changelist")
31 else:
32 form = CandidatEvaluationForm(candidat=candidat)
33
34 c = {'form' : form}
8ea41642 35 return render_to_response("recrutement/evaluer_candidat.html", Context(c),
596fe324 36 context_instance = RequestContext(request))
37
362a3534 38def affecter_evaluateurs_candidats(request):
39 candidat_ids = request.GET.get('ids').split(',')
596fe324 40 candidats = get_object_or_404(Candidat, id__in=candidat_ids)
362a3534 41 if request.method == "POST":
42 form = EvaluateurForm(request.POST, candidats=candidats)
43 if form.is_valid():
44 form.save()
45 messages.add_message(request, messages.SUCCESS,
46 "Les évaluateurs ont été affectés aux candidats.")
47 return redirect("admin:recrutement_candidat_changelist")
48 else:
49 form = EvaluateurForm(candidats=candidats)
50
51 c = {'form' : form}
8ea41642 52 return render_to_response("recrutement/affecter_evaluateurs.html",
53 Context(c), context_instance = RequestContext(request))
54
55def postuler_appel_offre(request):
2b3edf33 56 vars = dict()
8ea41642 57 offre_emploi = get_object_or_404(OffreEmploi, id=request.GET.get('id'))
58 candidat = Candidat()
59 candidat.offre_emploi = offre_emploi
2b3edf33 60
8ea41642 61 if request.method == "POST":
2b3edf33 62 form = PostulerOffreEmploiForm(request.POST, request.FILES, instance=candidat, offre_emploi=offre_emploi)
63 piecesForm = CandidatPieceForm(request.POST, request.FILES, instance=candidat)
64 #import pdb;pdb.set_trace()
65 if form.is_valid() and piecesForm.is_valid():
8ea41642 66 form.save()
67 messages.add_message(request, messages.SUCCESS,
68 "Votre application à l'appel d'offre d'emploi a \
69 été effectuée.")
70 return redirect("admin:recrutement_offreemploi_changelist")
71 else:
2b3edf33 72 form = PostulerOffreEmploiForm(instance=candidat, offre_emploi=offre_emploi)
73 piecesForm = CandidatPieceForm(instance=candidat)
8ea41642 74
2b3edf33 75 vars.update(dict(form=form, candidat=candidat, piecesForm=piecesForm, ))
76
77 return render_to_response('recrutement/postuler_appel_offre.html', vars,
78 RequestContext(request))