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