1 # -*- encoding: utf-8 -*-
4 from django
import forms
5 from django
.contrib
import admin
6 from django
.forms
.models
import inlineformset_factory
7 from datetime
import timedelta
8 from django
.forms
.widgets
import CheckboxSelectMultiple
9 from django
.contrib
.admin
import widgets
as admin_widgets
10 from form_utils
.forms
import BetterModelForm
11 from django
.forms
import ModelForm
12 from django
.forms
.models
import BaseInlineFormSet
13 from django
.core
.mail
import send_mail
15 from tinymce
.widgets
import TinyMCE
16 from captcha
.fields
import CaptchaField
18 from recrutement
import models
as recr
19 from auf
.django
.emploi
import forms
as emploi
23 ################################################################################
25 ################################################################################
26 class CandidatEvaluationForm(ModelForm
):
27 def __init__(self
, *args
, **kwargs
):
28 self
.candidat
= kwargs
.pop('candidat')
29 self
.evaluateur
= kwargs
.pop('evaluateur')
30 super(CandidatEvaluationForm
, self
).__init__(*args
, **kwargs
)
33 super(CandidatEvaluationForm
, self
).save()
36 fields
= ('note', 'commentaire')
37 model
= recr
.CandidatEvaluation
39 class EvaluateurForm(forms
.Form
):
40 evaluateurs
= forms
.ModelMultipleChoiceField(queryset
=
41 recr
.Evaluateur
.objects
.all())
43 def __init__(self
, *args
, **kwargs
):
44 self
.offres_emploi
= kwargs
.pop('offres_emploi')
45 super(EvaluateurForm
, self
).__init__(*args
, **kwargs
)
48 candidats
= recr
.Candidat
.objects
.\
49 filter(offre_emploi__in
=self
.offres_emploi
)
50 import pdb
;pdb
.set_trace()
51 for candidat
in candidats
:
52 for evaluateur
in self
.cleaned_data
.get('evaluateurs', []):
53 candidat_evaluation
= recr
.CandidatEvaluation()
54 candidat_evaluation
.candidat
= candidat
55 candidat_evaluation
.evaluateur
= evaluateur
56 candidat_evaluation
.save()
59 ################################################################################
61 ################################################################################
62 class CandidatPieceForm(emploi
.CandidatPieceForm
):
65 class PostulerOffreEmploiForm(emploi
.PostulerOffreEmploiForm
):
68 """class OffreEmploiForm(emploi.OffreEmploi):
70 cleaned_data = self.cleaned_data
71 date_limite = cleaned_data.get("date_limite")
72 debut_affectation = cleaned_data.get("debut_affectation")
74 if date_limite and debut_affectation:
75 if date_limite > debut_affectation:
76 raise forms.ValidationError("La date limite doit être \
77 ultérieure à la date de début d'affectation.")
80 ################################################################################
82 ################################################################################
83 class CandidatCourrielTemplateForm(ModelForm
):
84 def get_template(self
):
85 return self
.data
['template']
88 model
= recr
.CandidatCourriel
89 fields
= ('template', )
91 class CandidatCourrielForm(ModelForm
):
92 def __init__(self
, *args
, **kwargs
):
93 self
.candidats
= kwargs
.pop('candidats')
94 self
.template
= kwargs
.pop('template')
95 super(CandidatCourrielForm
, self
).__init__(*args
, **kwargs
)
98 super(CandidatCourrielForm
, self
).save()
101 model
= recr
.CandidatCourriel
102 fields
= ('sujet', 'plain_text', 'html')