1503: Permettre aux évaluateurs d'entrer des notes/commentaires sur les candidatures
[auf_rh_dae.git] / project / recrutement / views.py
1 # -*- encoding: utf-8 -*-
2 from django.shortcuts import redirect, render_to_response, get_object_or_404
3 from django.http import HttpResponse
4 from django.contrib import messages
5 from django.template import Context, RequestContext
6 from django.shortcuts import render_to_response, redirect
7 from django.template import RequestContext
8
9 from forms import *
10 from models import *
11 from project.recrutement import models as recr
12
13 def index(request):
14 return render_to_response('recrutement/index.html', {},
15 RequestContext(request))
16
17 def 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
23 form = CandidatEvaluationForm(request.POST, instance=candidat_evaluation, candidat=candidat)
24 if form.is_valid():
25 form.save()
26 messages.add_message(request, messages.SUCCESS,
27 "Le commentaire et la note ont été affectés \
28 au candidat.")
29 return redirect("admin:recrutement_candidat_changelist")
30 else:
31 form = CandidatEvaluationForm(candidat=candidat)
32
33 c = {'form' : form}
34 return render_to_response("recrutement/evaluer_candidat.html", Context(c), \
35 context_instance = RequestContext(request))
36
37 def affecter_evaluateurs_candidats(request):
38 candidat_ids = request.GET.get('ids').split(',')
39 candidats = get_object_or_404(Candidat, id__in=candidat_ids)
40 if request.method == "POST":
41 form = EvaluateurForm(request.POST, candidats=candidats)
42 if form.is_valid():
43 form.save()
44 messages.add_message(request, messages.SUCCESS,
45 "Les évaluateurs ont été affectés aux candidats.")
46 return redirect("admin:recrutement_candidat_changelist")
47 else:
48 form = EvaluateurForm(candidats=candidats)
49
50 c = {'form' : form}
51 return render_to_response("recrutement/affecter_evaluateurs.html", Context(c), context_instance = RequestContext(request))