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 | ||
36b8eabb | 10 | from models import * |
184b84de NBV |
11 | |
12 | ################################################################################ | |
13 | # OFFRE EMPLOI | |
14 | ################################################################################ | |
36b8eabb NBV |
15 | class CandidatPieceForm(inlineformset_factory(Candidat, |
16 | CandidatPiece)): | |
17 | nom = forms.MultipleChoiceField(choices=TYPE_PIECE_CHOICES, | |
184b84de NBV |
18 | widget=CheckboxSelectMultiple) |
19 | ||
3d78c976 NBV |
20 | |
21 | ||
184b84de NBV |
22 | class PostulerOffreEmploiForm(ModelForm): |
23 | captcha = CaptchaField() | |
36b8eabb | 24 | action = "http://127.0.0.1:8000/api/candidat_add/" |
184b84de NBV |
25 | |
26 | def __init__(self, *args, **kwargs): | |
36b8eabb | 27 | self.offre_emploi = kwargs.pop('offre_id') |
184b84de NBV |
28 | super(PostulerOffreEmploiForm, self).__init__(*args, **kwargs) |
29 | ||
30 | def save(self, *args, **kwargs): | |
31 | kwargs2 = kwargs.copy() | |
32 | kwargs2['commit'] = False | |
33 | postulation = super(PostulerOffreEmploiForm, self).save(*args, **kwargs2) | |
34 | if 'commit' not in kwargs or kwargs['commit']: | |
35 | postulation.save() | |
36 | return postulation | |
37 | ||
38 | class Meta: | |
36b8eabb | 39 | model = Candidat |
184b84de NBV |
40 | exclude = ('actif', 'offre_emploi',) |
41 | fields = ('nom', 'prenom', 'genre', 'nationalite', 'situation_famille', | |
42 | 'nombre_dependant', 'niveau_diplome', 'employeur_actuel', | |
43 | 'poste_actuel', 'domaine_professionnel', 'telephone', | |
44 | 'email', 'adresse', 'ville', 'code_postal', 'etat_province', | |
45 | 'pays', 'captcha', ) |