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