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 django
.core
.mail
import send_mail
19 #from recrutement.lib import send_templated_mail
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
.candidats
= kwargs
.pop('candidats')
43 super(EvaluateurForm
, self
).__init__(*args
, **kwargs
)
46 for candidat
in self
.candidats
:
47 for evaluateur
in self
.cleaned_data
.get('evaluateurs', []):
48 candidat_evaluation
= recr
.CandidatEvaluation()
49 candidat_evaluation
.candidat
= candidat
50 candidat_evaluation
.evaluateur
= evaluateur
51 candidat_evaluation
.save()
53 ################################################################################
55 ################################################################################
56 class CandidatPieceForm(inlineformset_factory(recr
.Candidat
,
58 nom
= forms
.MultipleChoiceField(choices
=recr
.TYPE_PIECE_CHOICES
,
59 widget
=CheckboxSelectMultiple
)
61 class PostulerOffreEmploiForm(ModelForm
):
62 captcha
= CaptchaField()
64 def __init__(self
, *args
, **kwargs
):
65 self
.offre_emploi
= kwargs
.pop('offre_emploi')
66 super(PostulerOffreEmploiForm
, self
).__init__(*args
, **kwargs
)
68 def save(self
, *args
, **kwargs
):
69 kwargs2
= kwargs
.copy()
70 kwargs2
['commit'] = False
71 postulation
= super(PostulerOffreEmploiForm
, self
).save(*args
, **kwargs2
)
72 if 'commit' not in kwargs
or kwargs
['commit']:
78 exclude
= ('actif', 'offre_emploi',)
79 fields
= ('nom', 'prenom', 'genre', 'nationalite', 'situation_famille',
80 'nombre_dependant', 'niveau_diplome', 'employeur_actuel',
81 'poste_actuel', 'domaine_professionnel', 'telephone',
82 'email', 'adresse', 'ville', 'code_postal', 'etat_province',
85 ################################################################################
87 ################################################################################
88 class CandidatCourrielTemplateForm(ModelForm
):
89 def get_template(self
):
90 return self
.data
['template']
93 model
= recr
.CandidatCourriel
94 fields
= ('template', )
96 class CandidatCourrielForm(ModelForm
):
97 def __init__(self
, *args
, **kwargs
):
98 self
.candidats
= kwargs
.pop('candidats')
99 self
.template
= kwargs
.pop('template')
100 super(CandidatCourrielForm
, self
).__init__(*args
, **kwargs
)
103 super(CandidatCourrielForm
, self
).save()
106 model
= recr
.CandidatCourriel
107 fields
= ('sujet', 'plain_text', 'html')