refactoring pour couplage fort model form, abstraction utilisation JSON
[auf_django_emploi.git] / auf / django / emploi / forms.py
CommitLineData
184b84de
NBV
1# -*- encoding: utf-8 -*-
2
184b84de 3from django import forms
184b84de
NBV
4from django.forms.models import inlineformset_factory
5from django.forms.widgets import CheckboxSelectMultiple
6from django.forms import ModelForm
7
8from captcha.fields import CaptchaField
9
36b8eabb 10from models import *
184b84de
NBV
11
12################################################################################
13# OFFRE EMPLOI
14################################################################################
36b8eabb
NBV
15class CandidatPieceForm(inlineformset_factory(Candidat,
16 CandidatPiece)):
17 nom = forms.MultipleChoiceField(choices=TYPE_PIECE_CHOICES,
184b84de
NBV
18 widget=CheckboxSelectMultiple)
19
3d78c976
NBV
20 def __init__(self, *args, **kwargs):
21 super(CandidatPieceForm, self).__init__(*args, **kwargs)
22
23 def save(self, *args, **kwargs):
24 super(CandidatPieceForm, self).save(*args, **kwargs)
25
26
77dc3c2f
OL
27POSTULER_FORM_EXCLUDES = ('actif', 'offre_emploi',)
28POSTULER_FORM_FIELDS = ('nom', 'prenom', 'genre', 'nationalite', 'situation_famille',
29 'nombre_dependant', 'niveau_diplome', 'employeur_actuel',
30 'poste_actuel', 'domaine_professionnel', 'telephone',
31 'email', 'adresse', 'ville', 'code_postal', 'etat_province',
32 'pays', )
184b84de 33
77dc3c2f
OL
34class NoCaptchaPostulerOffreEmploiForm(ModelForm):
35 class Meta:
36 model = Candidat
37 exclude = POSTULER_FORM_EXCLUDES
38 fields = POSTULER_FORM_FIELDS
184b84de 39
77dc3c2f
OL
40class PostulerOffreEmploiForm(ModelForm):
41 captcha = CaptchaField()
184b84de
NBV
42
43 class Meta:
36b8eabb 44 model = Candidat
77dc3c2f
OL
45 exclude = POSTULER_FORM_EXCLUDES
46 fields = POSTULER_FORM_FIELDS + ('captcha', )