| 1 | # -*- encoding: utf-8 -*- |
| 2 | |
| 3 | from django import forms |
| 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 | |
| 10 | from models import * |
| 11 | |
| 12 | ################################################################################ |
| 13 | # OFFRE EMPLOI |
| 14 | ################################################################################ |
| 15 | class CandidatPieceForm(inlineformset_factory(Candidat, |
| 16 | CandidatPiece)): |
| 17 | nom = forms.MultipleChoiceField(choices=TYPE_PIECE_CHOICES, |
| 18 | widget=CheckboxSelectMultiple) |
| 19 | |
| 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 | |
| 27 | POSTULER_FORM_EXCLUDES = ('actif', 'offre_emploi',) |
| 28 | POSTULER_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', ) |
| 33 | |
| 34 | class NoCaptchaPostulerOffreEmploiForm(ModelForm): |
| 35 | class Meta: |
| 36 | model = Candidat |
| 37 | exclude = POSTULER_FORM_EXCLUDES |
| 38 | fields = POSTULER_FORM_FIELDS |
| 39 | |
| 40 | class PostulerOffreEmploiForm(ModelForm): |
| 41 | captcha = CaptchaField() |
| 42 | |
| 43 | class Meta: |
| 44 | model = Candidat |
| 45 | exclude = POSTULER_FORM_EXCLUDES |
| 46 | fields = POSTULER_FORM_FIELDS + ('captcha', ) |