83252c4c |
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 |
8ea41642 |
7 | from form_utils.forms import BetterModelForm |
83252c4c |
8 | from django.forms import ModelForm |
2b3edf33 |
9 | from recrutement import models as recr |
10 | from django.forms.models import BaseInlineFormSet |
83252c4c |
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') |
2b3edf33 |
25 | model = recr.CandidatEvaluation |
83252c4c |
26 | |
27 | class EvaluateurForm(forms.Form): |
8ea41642 |
28 | evaluateurs = forms.ModelMultipleChoiceField(queryset= |
f083eee0 |
29 | recr.User.objects.all()) |
83252c4c |
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 | ################################################################################ |
2b3edf33 |
43 | class CandidatPieceForm(inlineformset_factory(recr.Candidat, recr.CandidatPiece)): |
44 | pass |
45 | |
46 | class PostulerOffreEmploiForm(ModelForm): |
47 | def __init__(self, *args, **kwargs): |
2adf9e0c |
48 | self.offre_emploi = kwargs.pop('offre_emploi') |
8ea41642 |
49 | super(PostulerOffreEmploiForm, self).__init__(*args, **kwargs) |
50 | |
51 | def save(self): |
52 | super(PostulerOffreEmploiForm, self).save() |
53 | |
83252c4c |
54 | class Meta: |
2b3edf33 |
55 | model = recr.Candidat |
56 | exclude = ('actif', 'offre_emploi',) |
57 | fields = ('nom', 'prenom', 'genre', 'nationalite', 'date_naissance', |
58 | 'situation_famille', 'nombre_dependant', 'niveau_diplome', |
59 | 'employeur_actuel', 'poste_actuel', 'domaine_professionnel', |
60 | 'adresse', 'ville', 'etat_province', 'pays', ) |