nom = forms.MultipleChoiceField(choices=TYPE_PIECE_CHOICES,
widget=CheckboxSelectMultiple)
- def __init__(self, *args, **kwargs):
- super(CandidatPieceForm, self).__init__(*args, **kwargs)
-
- def save(self, *args, **kwargs):
- super(CandidatPieceForm, self).save(*args, **kwargs)
- class PostulerOffreEmploiForm(ModelForm):
- captcha = CaptchaField()
- action = "http://127.0.0.1:8000/api/candidat_add/"
+ 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', )
- def __init__(self, *args, **kwargs):
- self.offre_emploi = kwargs.pop('offre_id')
- super(PostulerOffreEmploiForm, self).__init__(*args, **kwargs)
+ class NoCaptchaPostulerOffreEmploiForm(ModelForm):
+ class Meta:
+ model = Candidat
+ exclude = POSTULER_FORM_EXCLUDES
+ fields = POSTULER_FORM_FIELDS
- 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 PostulerOffreEmploiForm(ModelForm):
+ captcha = CaptchaField()
class Meta:
model = Candidat