8987fa5f11870f3460d4033225a35254eb9f3e7c
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 django
.forms
.widgets
import CheckboxSelectMultiple
8 from django
.forms
import ModelForm
10 from captcha
.fields
import CaptchaField
12 from recrutement
import models
as recr
14 ################################################################################
16 ################################################################################
17 class CandidatPieceForm(inlineformset_factory(recr
.Candidat
,
19 nom
= forms
.MultipleChoiceField(choices
=recr
.TYPE_PIECE_CHOICES
,
20 widget
=CheckboxSelectMultiple
)
22 class PostulerOffreEmploiForm(ModelForm
):
23 captcha
= CaptchaField()
25 def __init__(self
, *args
, **kwargs
):
26 self
.offre_emploi
= kwargs
.pop('offre_emploi')
27 super(PostulerOffreEmploiForm
, self
).__init__(*args
, **kwargs
)
29 def save(self
, *args
, **kwargs
):
30 kwargs2
= kwargs
.copy()
31 kwargs2
['commit'] = False
32 postulation
= super(PostulerOffreEmploiForm
, self
).save(*args
, **kwargs2
)
33 if 'commit' not in kwargs
or kwargs
['commit']:
39 exclude
= ('actif', 'offre_emploi',)
40 fields
= ('nom', 'prenom', 'genre', 'nationalite', 'situation_famille',
41 'nombre_dependant', 'niveau_diplome', 'employeur_actuel',
42 'poste_actuel', 'domaine_professionnel', 'telephone',
43 'email', 'adresse', 'ville', 'code_postal', 'etat_province',
46 # TODO: Vérifier si on garde, pour l'envoi automatique d'un email lors de la
47 # postulation de l'offre d'emploi
48 ################################################################################
50 ################################################################################
51 class CandidatCourrielTemplateForm(ModelForm
):
52 def get_template(self
):
53 return self
.data
['template']
56 model
= recr
.CandidatCourriel
57 fields
= ('template', )
59 class CandidatCourrielForm(ModelForm
):
60 def __init__(self
, *args
, **kwargs
):
61 self
.candidats
= kwargs
.pop('candidats')
62 self
.template
= kwargs
.pop('template')
63 super(CandidatCourrielForm
, self
).__init__(*args
, **kwargs
)
66 super(CandidatCourrielForm
, self
).save()
69 model
= recr
.CandidatCourriel
70 fields
= ('sujet', 'plain_text', 'html')