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 form_utils
.forms
import BetterModelForm
8 from django
.forms
import ModelForm
9 from django
.forms
.models
import BaseInlineFormSet
10 from tinymce
.widgets
import TinyMCE
11 from captcha
.fields
import CaptchaField
13 from recrutement
import models
as recr
15 ################################################################################
17 ################################################################################
18 class CandidatEvaluationForm(ModelForm
):
19 def __init__(self
, *args
, **kwargs
):
20 self
.candidat
= kwargs
.pop('candidat')
21 self
.evaluateur
= kwargs
.pop('evaluateur')
22 super(CandidatEvaluationForm
, self
).__init__(*args
, **kwargs
)
25 super(CandidatEvaluationForm
, self
).save()
28 fields
= ('note', 'commentaire')
29 model
= recr
.CandidatEvaluation
31 class EvaluateurForm(forms
.Form
):
32 evaluateurs
= forms
.ModelMultipleChoiceField(queryset
=
33 recr
.UserProfile
.objects
.all())
35 def __init__(self
, *args
, **kwargs
):
36 self
.candidats
= kwargs
.pop('candidats')
37 super(EvaluateurForm
, self
).__init__(*args
, **kwargs
)
40 for d
in self
.candidats
:
41 d
.evaluateurs
= self
.cleaned_data
.get('evaluateurs', [])
44 ################################################################################
46 ################################################################################
47 class CandidatPieceForm(inlineformset_factory(recr
.Candidat
,
51 class PostulerOffreEmploiForm(ModelForm
):
52 captcha
= CaptchaField()
54 def __init__(self
, *args
, **kwargs
):
55 self
.offre_emploi
= kwargs
.pop('offre_emploi')
56 super(PostulerOffreEmploiForm
, self
).__init__(*args
, **kwargs
)
58 def save(self
, *args
, **kwargs
):
59 kwargs2
= kwargs
.copy()
60 kwargs2
['commit'] = False
61 postulation
= super(PostulerOffreEmploiForm
, self
).save(*args
, **kwargs2
)
62 if 'commit' not in kwargs
or kwargs
['commit']:
68 exclude
= ('actif', 'offre_emploi',)
69 fields
= ('nom', 'prenom', 'genre', 'nationalite', 'date_naissance',
70 'situation_famille', 'nombre_dependant', 'niveau_diplome',
71 'employeur_actuel', 'poste_actuel', 'domaine_professionnel',
72 'telephone', 'email', 'adresse', 'ville', 'code_postal',
73 'etat_province', 'pays', 'captcha', )