Commit | Line | Data |
---|---|---|
184b84de NBV |
1 | # -*- encoding: utf-8 -*- |
2 | ||
184b84de | 3 | from django import forms |
184b84de NBV |
4 | from django.forms.models import inlineformset_factory |
5 | from django.forms.widgets import CheckboxSelectMultiple | |
6 | from django.forms import ModelForm | |
7 | ||
8 | from captcha.fields import CaptchaField | |
9 | ||
50280cae | 10 | from auf.django.emploi import models as emploi |
184b84de NBV |
11 | |
12 | ################################################################################ | |
13 | # OFFRE EMPLOI | |
14 | ################################################################################ | |
50280cae NBV |
15 | class CandidatPieceForm(inlineformset_factory(emploi.Candidat, |
16 | emploi.CandidatPiece)): | |
17 | nom = forms.MultipleChoiceField(choices=emploi.TYPE_PIECE_CHOICES, | |
184b84de NBV |
18 | widget=CheckboxSelectMultiple) |
19 | ||
20 | class PostulerOffreEmploiForm(ModelForm): | |
21 | captcha = CaptchaField() | |
22 | ||
23 | def __init__(self, *args, **kwargs): | |
24 | self.offre_emploi = kwargs.pop('offre_emploi') | |
25 | super(PostulerOffreEmploiForm, self).__init__(*args, **kwargs) | |
26 | ||
27 | def save(self, *args, **kwargs): | |
28 | kwargs2 = kwargs.copy() | |
29 | kwargs2['commit'] = False | |
30 | postulation = super(PostulerOffreEmploiForm, self).save(*args, **kwargs2) | |
31 | if 'commit' not in kwargs or kwargs['commit']: | |
32 | postulation.save() | |
33 | return postulation | |
34 | ||
35 | class Meta: | |
50280cae | 36 | model = emploi.Candidat |
184b84de NBV |
37 | exclude = ('actif', 'offre_emploi',) |
38 | fields = ('nom', 'prenom', 'genre', 'nationalite', 'situation_famille', | |
39 | 'nombre_dependant', 'niveau_diplome', 'employeur_actuel', | |
40 | 'poste_actuel', 'domaine_professionnel', 'telephone', | |
41 | 'email', 'adresse', 'ville', 'code_postal', 'etat_province', | |
42 | 'pays', 'captcha', ) |