1592: Modeles- Remplacer Evaluateur par User
[auf_rh_dae.git] / project / recrutement / forms.py
1 # -*- encoding: utf-8 -*-
2
3 import os
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 recrutement import models as recr
10 from django.forms.models import BaseInlineFormSet
11
12 ################################################################################
13 # EVALUATION
14 ################################################################################
15 class CandidatEvaluationForm(ModelForm):
16 def __init__(self, *args, **kwargs):
17 self.candidat = kwargs.pop('candidat')
18 super(CandidatEvaluationForm, self).__init__(*args, **kwargs)
19
20 def save(self):
21 super(CandidatEvaluationForm, self).save()
22
23 class Meta:
24 fields = ('note', 'commentaire', 'evaluateur')
25 model = recr.CandidatEvaluation
26
27 class EvaluateurForm(forms.Form):
28 evaluateurs = forms.ModelMultipleChoiceField(queryset=
29 recr.User.objects.all())
30
31 def __init__(self, *args, **kwargs):
32 self.candidats = kwargs.pop('candidats')
33 super(EvaluateurForm, self).__init__(*args, **kwargs)
34
35 def save(self):
36 for d in self.candidats:
37 d.evaluateurs = self.cleaned_data.get('evaluateurs', [])
38 d.save()
39
40 ################################################################################
41 # OFFRE EMPLOI
42 ################################################################################
43 class CandidatPieceForm(inlineformset_factory(recr.Candidat, recr.CandidatPiece)):
44 pass
45
46 class PostulerOffreEmploiForm(ModelForm):
47 def __init__(self, *args, **kwargs):
48 self.offre_emploi = kwargs.pop('offre_emploi')
49 #import pdb;pdb.set_trace()
50 super(PostulerOffreEmploiForm, self).__init__(*args, **kwargs)
51
52 def save(self):
53 super(PostulerOffreEmploiForm, self).save()
54
55 class Meta:
56 model = recr.Candidat
57 exclude = ('actif', 'offre_emploi',)
58 fields = ('nom', 'prenom', 'genre', 'nationalite', 'date_naissance',
59 'situation_famille', 'nombre_dependant', 'niveau_diplome',
60 'employeur_actuel', 'poste_actuel', 'domaine_professionnel',
61 'adresse', 'ville', 'etat_province', 'pays', )