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 | ||
12 | from recrutement import models as recr | |
13 | ||
14 | ################################################################################ | |
15 | # OFFRE EMPLOI | |
16 | ################################################################################ | |
17 | class CandidatPieceForm(inlineformset_factory(recr.Candidat, | |
18 | recr.CandidatPiece)): | |
19 | nom = forms.MultipleChoiceField(choices=recr.TYPE_PIECE_CHOICES, | |
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: | |
38 | model = recr.Candidat | |
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', ) | |
45 | ||
46 | # TODO: Vérifier si on garde, pour l'envoi automatique d'un email lors de la | |
47 | # postulation de l'offre d'emploi | |
48 | ################################################################################ | |
49 | # TEMPLATE COURRIEL | |
50 | ################################################################################ | |
51 | class CandidatCourrielTemplateForm(ModelForm): | |
52 | def get_template(self): | |
53 | return self.data['template'] | |
54 | ||
55 | class Meta: | |
56 | model = recr.CandidatCourriel | |
57 | fields = ('template', ) | |
58 | ||
59 | class CandidatCourrielForm(ModelForm): | |
60 | def __init__(self, *args, **kwargs): | |
61 | self.candidats = kwargs.pop('candidats') | |
62 | self.template = kwargs.pop('template') | |
63 | super(CandidatCourrielForm, self).__init__(*args, **kwargs) | |
64 | ||
65 | def save(self): | |
66 | super(CandidatCourrielForm, self).save() | |
67 | ||
68 | class Meta: | |
69 | model = recr.CandidatCourriel | |
70 | fields = ('sujet', 'plain_text', 'html') | |
71 |