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
14 from tinymce
.widgets
import TinyMCE
15 from captcha
.fields
import CaptchaField
17 from recrutement
import models
as recr
18 #from recrutement.lib import send_templated_mail
20 ################################################################################
22 ################################################################################
23 class CandidatEvaluationForm(ModelForm
):
24 def __init__(self
, *args
, **kwargs
):
25 self
.candidat
= kwargs
.pop('candidat')
26 self
.evaluateur
= kwargs
.pop('evaluateur')
27 super(CandidatEvaluationForm
, self
).__init__(*args
, **kwargs
)
30 super(CandidatEvaluationForm
, self
).save()
33 fields
= ('note', 'commentaire')
34 model
= recr
.CandidatEvaluation
36 class EvaluateurForm(forms
.Form
):
37 evaluateurs
= forms
.ModelMultipleChoiceField(queryset
=
38 recr
.Evaluateur
.objects
.all())
40 def __init__(self
, *args
, **kwargs
):
41 self
.candidats
= kwargs
.pop('candidats')
42 super(EvaluateurForm
, self
).__init__(*args
, **kwargs
)
45 for d
in self
.candidats
:
46 d
.evaluateurs
= self
.cleaned_data
.get('evaluateurs', [])
49 ################################################################################
51 ################################################################################
52 class CandidatPieceForm(inlineformset_factory(recr
.Candidat
,
54 nom
= forms
.MultipleChoiceField(choices
=recr
.TYPE_PIECE_CHOICES
,
55 widget
=CheckboxSelectMultiple
)
57 class PostulerOffreEmploiForm(ModelForm
):
58 captcha
= CaptchaField()
60 def __init__(self
, *args
, **kwargs
):
61 self
.offre_emploi
= kwargs
.pop('offre_emploi')
62 super(PostulerOffreEmploiForm
, self
).__init__(*args
, **kwargs
)
64 def save(self
, *args
, **kwargs
):
65 kwargs2
= kwargs
.copy()
66 kwargs2
['commit'] = False
67 postulation
= super(PostulerOffreEmploiForm
, self
).save(*args
, **kwargs2
)
68 if 'commit' not in kwargs
or kwargs
['commit']:
74 exclude
= ('actif', 'offre_emploi',)
75 widgets
= dict(date_naissance
=admin_widgets
.AdminDateWidget(),)
76 fields
= ('nom', 'prenom', 'genre', 'nationalite', 'date_naissance',
77 'situation_famille', 'nombre_dependant', 'niveau_diplome',
78 'employeur_actuel', 'poste_actuel', 'domaine_professionnel',
79 'telephone', 'email', 'adresse', 'ville', 'code_postal',
80 'etat_province', 'pays', 'captcha', )
82 ################################################################################
84 ################################################################################
85 class CandidatCourrielForm(ModelForm
):
86 #texte = forms.CharField(widget=TinyMCE())
88 def __init__(self
, *args
, **kwargs
):
89 self
.candidats
= kwargs
.pop('candidats')
90 super(CandidatCourrielForm
, self
).__init__(*args
, **kwargs
)
93 super(CandidatCourrielForm
, self
).save()
94 #for cand in self.candidats:
95 #send_templated_mail()
98 model
= recr
.CandidatCourriel
99 fields
= ('template','titre', 'texte')