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 django.forms.models import BaseInlineFormSet |
ec517164 |
10 | from tinymce.widgets import TinyMCE |
86caaf03 |
11 | from captcha.fields import CaptchaField |
ec517164 |
12 | |
13 | from recrutement import models as recr |
83252c4c |
14 | |
15 | ################################################################################ |
16 | # EVALUATION |
17 | ################################################################################ |
18 | class CandidatEvaluationForm(ModelForm): |
19 | def __init__(self, *args, **kwargs): |
20 | self.candidat = kwargs.pop('candidat') |
e34a2ae0 |
21 | self.evaluateur = kwargs.pop('evaluateur') |
83252c4c |
22 | super(CandidatEvaluationForm, self).__init__(*args, **kwargs) |
23 | |
24 | def save(self): |
25 | super(CandidatEvaluationForm, self).save() |
26 | |
27 | class Meta: |
e34a2ae0 |
28 | fields = ('note', 'commentaire') |
2b3edf33 |
29 | model = recr.CandidatEvaluation |
83252c4c |
30 | |
31 | class EvaluateurForm(forms.Form): |
8ea41642 |
32 | evaluateurs = forms.ModelMultipleChoiceField(queryset= |
f6749f29 |
33 | recr.UserProfile.objects.all()) |
83252c4c |
34 | |
35 | def __init__(self, *args, **kwargs): |
36 | self.candidats = kwargs.pop('candidats') |
37 | super(EvaluateurForm, self).__init__(*args, **kwargs) |
38 | |
39 | def save(self): |
40 | for d in self.candidats: |
41 | d.evaluateurs = self.cleaned_data.get('evaluateurs', []) |
42 | d.save() |
43 | |
44 | ################################################################################ |
45 | # OFFRE EMPLOI |
46 | ################################################################################ |
f6749f29 |
47 | class CandidatPieceForm(inlineformset_factory(recr.Candidat, |
48 | recr.CandidatPiece)): |
2b3edf33 |
49 | pass |
50 | |
51 | class PostulerOffreEmploiForm(ModelForm): |
86caaf03 |
52 | captcha = CaptchaField() |
53 | |
2b3edf33 |
54 | def __init__(self, *args, **kwargs): |
2adf9e0c |
55 | self.offre_emploi = kwargs.pop('offre_emploi') |
8ea41642 |
56 | super(PostulerOffreEmploiForm, self).__init__(*args, **kwargs) |
57 | |
f6749f29 |
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']: |
63 | postulation.save() |
64 | return postulation |
8ea41642 |
65 | |
83252c4c |
66 | class Meta: |
2b3edf33 |
67 | model = recr.Candidat |
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', |
ec517164 |
72 | 'telephone', 'email', 'adresse', 'ville', 'code_postal', |
86caaf03 |
73 | 'etat_province', 'pays', 'captcha', ) |
ec517164 |
74 | |