Commit | Line | Data |
---|---|---|
83252c4c | 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 | |
ee42ad96 | 7 | from datetime import timedelta |
8 | from django.forms.widgets import CheckboxSelectMultiple | |
9 | from django.contrib.admin import widgets as admin_widgets | |
8ea41642 | 10 | from form_utils.forms import BetterModelForm |
83252c4c | 11 | from django.forms import ModelForm |
2b3edf33 | 12 | from django.forms.models import BaseInlineFormSet |
240940e1 | 13 | from django.core.mail import send_mail |
ee42ad96 | 14 | |
ec517164 | 15 | from tinymce.widgets import TinyMCE |
86caaf03 | 16 | from captcha.fields import CaptchaField |
ec517164 | 17 | |
18 | from recrutement import models as recr | |
240940e1 NBV |
19 | from auf.django.emploi import forms as emploi |
20 | ||
21 | ||
83252c4c | 22 | |
23 | ################################################################################ | |
24 | # EVALUATION | |
25 | ################################################################################ | |
26 | class CandidatEvaluationForm(ModelForm): | |
27 | def __init__(self, *args, **kwargs): | |
28 | self.candidat = kwargs.pop('candidat') | |
e34a2ae0 | 29 | self.evaluateur = kwargs.pop('evaluateur') |
83252c4c | 30 | super(CandidatEvaluationForm, self).__init__(*args, **kwargs) |
31 | ||
32 | def save(self): | |
33 | super(CandidatEvaluationForm, self).save() | |
34 | ||
35 | class Meta: | |
e34a2ae0 | 36 | fields = ('note', 'commentaire') |
2b3edf33 | 37 | model = recr.CandidatEvaluation |
83252c4c | 38 | |
39 | class EvaluateurForm(forms.Form): | |
8ea41642 | 40 | evaluateurs = forms.ModelMultipleChoiceField(queryset= |
27c81d11 | 41 | recr.Evaluateur.objects.all()) |
83252c4c | 42 | |
43 | def __init__(self, *args, **kwargs): | |
540dfae4 | 44 | self.offres_emploi = kwargs.pop('offres_emploi') |
83252c4c | 45 | super(EvaluateurForm, self).__init__(*args, **kwargs) |
46 | ||
47 | def save(self): | |
540dfae4 NBV |
48 | candidats = recr.Candidat.objects.\ |
49 | filter(offre_emploi__in=self.offres_emploi) | |
50 | import pdb;pdb.set_trace() | |
51 | for candidat in candidats: | |
21b02da5 | 52 | for evaluateur in self.cleaned_data.get('evaluateurs', []): |
c4874d66 | 53 | candidat_evaluation = recr.CandidatEvaluation() |
21b02da5 NBV |
54 | candidat_evaluation.candidat = candidat |
55 | candidat_evaluation.evaluateur = evaluateur | |
c4874d66 | 56 | candidat_evaluation.save() |
540dfae4 | 57 | |
83252c4c | 58 | |
59 | ################################################################################ | |
60 | # OFFRE EMPLOI | |
61 | ################################################################################ | |
240940e1 NBV |
62 | class CandidatPieceForm(emploi.CandidatPieceForm): |
63 | pass | |
86caaf03 | 64 | |
240940e1 NBV |
65 | class PostulerOffreEmploiForm(emploi.PostulerOffreEmploiForm): |
66 | pass | |
ec517164 | 67 | |
540dfae4 NBV |
68 | """class OffreEmploiForm(emploi.OffreEmploi): |
69 | def clean(self): | |
70 | cleaned_data = self.cleaned_data | |
71 | date_limite = cleaned_data.get("date_limite") | |
72 | debut_affectation = cleaned_data.get("debut_affectation") | |
73 | ||
74 | if date_limite and debut_affectation: | |
75 | if date_limite > debut_affectation: | |
76 | raise forms.ValidationError("La date limite doit être \ | |
77 | ultérieure à la date de début d'affectation.") | |
78 | return cleaned_data | |
79 | """ | |
d84c3a68 | 80 | ################################################################################ |
81 | # TEMPLATE COURRIEL | |
82 | ################################################################################ | |
32834000 NBV |
83 | class CandidatCourrielTemplateForm(ModelForm): |
84 | def get_template(self): | |
85 | return self.data['template'] | |
d84c3a68 | 86 | |
32834000 NBV |
87 | class Meta: |
88 | model = recr.CandidatCourriel | |
89 | fields = ('template', ) | |
90 | ||
91 | class CandidatCourrielForm(ModelForm): | |
d84c3a68 | 92 | def __init__(self, *args, **kwargs): |
93 | self.candidats = kwargs.pop('candidats') | |
32834000 | 94 | self.template = kwargs.pop('template') |
d84c3a68 | 95 | super(CandidatCourrielForm, self).__init__(*args, **kwargs) |
96 | ||
97 | def save(self): | |
98 | super(CandidatCourrielForm, self).save() | |
99 | ||
100 | class Meta: | |
101 | model = recr.CandidatCourriel | |
32834000 | 102 | fields = ('sujet', 'plain_text', 'html') |
d84c3a68 | 103 |