X-Git-Url: http://git.auf.org/?p=auf_django_emploi.git;a=blobdiff_plain;f=auf%2Fdjango%2Femploi%2Fforms.py;h=28017383b358c5568cf8712d81e4b18d8cc31d19;hp=79338eb2142a2f25aa1d59b4f6d944b04ac79404;hb=77dc3c2ff40f4561d07bcbfa05b4bfd49cae9a3c;hpb=36b8eabbdf161a658084dd56963f23e001691477 diff --git a/auf/django/emploi/forms.py b/auf/django/emploi/forms.py index 79338eb..2801738 100644 --- a/auf/django/emploi/forms.py +++ b/auf/django/emploi/forms.py @@ -17,27 +17,30 @@ class CandidatPieceForm(inlineformset_factory(Candidat, nom = forms.MultipleChoiceField(choices=TYPE_PIECE_CHOICES, widget=CheckboxSelectMultiple) -class PostulerOffreEmploiForm(ModelForm): - captcha = CaptchaField() - action = "http://127.0.0.1:8000/api/candidat_add/" - def __init__(self, *args, **kwargs): - self.offre_emploi = kwargs.pop('offre_id') - super(PostulerOffreEmploiForm, self).__init__(*args, **kwargs) + super(CandidatPieceForm, self).__init__(*args, **kwargs) + + def save(self, *args, **kwargs): + super(CandidatPieceForm, self).save(*args, **kwargs) - def save(self, *args, **kwargs): - kwargs2 = kwargs.copy() - kwargs2['commit'] = False - postulation = super(PostulerOffreEmploiForm, self).save(*args, **kwargs2) - if 'commit' not in kwargs or kwargs['commit']: - postulation.save() - return postulation - class Meta: - model = Candidat - exclude = ('actif', 'offre_emploi',) - fields = ('nom', 'prenom', 'genre', 'nationalite', 'situation_famille', +POSTULER_FORM_EXCLUDES = ('actif', 'offre_emploi',) +POSTULER_FORM_FIELDS = ('nom', 'prenom', 'genre', 'nationalite', 'situation_famille', 'nombre_dependant', 'niveau_diplome', 'employeur_actuel', 'poste_actuel', 'domaine_professionnel', 'telephone', 'email', 'adresse', 'ville', 'code_postal', 'etat_province', - 'pays', 'captcha', ) + 'pays', ) + +class NoCaptchaPostulerOffreEmploiForm(ModelForm): + class Meta: + model = Candidat + exclude = POSTULER_FORM_EXCLUDES + fields = POSTULER_FORM_FIELDS + +class PostulerOffreEmploiForm(ModelForm): + captcha = CaptchaField() + + class Meta: + model = Candidat + exclude = POSTULER_FORM_EXCLUDES + fields = POSTULER_FORM_FIELDS + ('captcha', )