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
21 ################################################################################
23 ################################################################################
24 class CandidatEvaluationForm(ModelForm
):
25 def __init__(self
, *args
, **kwargs
):
26 self
.candidat
= kwargs
.pop('candidat')
27 self
.evaluateur
= kwargs
.pop('evaluateur')
28 super(CandidatEvaluationForm
, self
).__init__(*args
, **kwargs
)
31 super(CandidatEvaluationForm
, self
).save()
34 fields
= ('note', 'commentaire')
35 model
= recr
.CandidatEvaluation
37 class EvaluateurForm(forms
.Form
):
38 evaluateurs
= forms
.ModelMultipleChoiceField(queryset
=
39 recr
.Evaluateur
.objects
.all())
41 def __init__(self
, *args
, **kwargs
):
42 self
.offres_emploi
= kwargs
.pop('offres_emploi')
43 super(EvaluateurForm
, self
).__init__(*args
, **kwargs
)
46 candidats
= recr
.Candidat
.objects
.\
47 filter(offre_emploi__in
=self
.offres_emploi
)
48 for candidat
in candidats
:
49 for evaluateur
in self
.cleaned_data
.get('evaluateurs', []):
50 candidat_evaluation
= recr
.CandidatEvaluation()
51 candidat_evaluation
.candidat
= candidat
52 candidat_evaluation
.evaluateur
= evaluateur
53 candidat_evaluation
.save()
56 ################################################################################
58 ################################################################################
59 class CandidatPieceForm(emploi
.CandidatPieceForm
):
62 class PostulerOffreEmploiForm(emploi
.PostulerOffreEmploiForm
):
65 class OffreEmploiForm(ModelForm
):
67 model
= recr
.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 ne peut pas être \
77 supérieure à la date d'affection.")
81 ################################################################################
83 ################################################################################
84 class CandidatCourrielTemplateForm(ModelForm
):
85 def get_template(self
):
86 return self
.data
['template']
89 model
= recr
.CandidatCourriel
90 fields
= ('template', )
92 class CandidatCourrielForm(ModelForm
):
93 def __init__(self
, *args
, **kwargs
):
94 self
.candidats
= kwargs
.pop('candidats')
95 self
.template
= kwargs
.pop('template')
96 super(CandidatCourrielForm
, self
).__init__(*args
, **kwargs
)
99 super(CandidatCourrielForm
, self
).save()
102 model
= recr
.CandidatCourriel
103 fields
= ('sujet', 'plain_text', 'html')