Retrait de forms non-pertinent dans le package
[auf_rh_dae.git] / project / recrutement / forms.py
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 datetime import timedelta
8 from django.forms.widgets import CheckboxSelectMultiple
9 from django.contrib.admin import widgets as admin_widgets
10 from form_utils.forms import BetterModelForm
11 from django.forms import ModelForm
12 from django.forms.models import BaseInlineFormSet
13 from django.core.mail import send_mail
14
15 from tinymce.widgets import TinyMCE
16 from captcha.fields import CaptchaField
17
18 from recrutement import models as recr
19 from auf.django.emploi import forms as emploi
20
21
22
23 ################################################################################
24 # EVALUATION
25 ################################################################################
26 class CandidatEvaluationForm(ModelForm):
27 def __init__(self, *args, **kwargs):
28 self.candidat = kwargs.pop('candidat')
29 self.evaluateur = kwargs.pop('evaluateur')
30 super(CandidatEvaluationForm, self).__init__(*args, **kwargs)
31
32 def save(self):
33 super(CandidatEvaluationForm, self).save()
34
35 class Meta:
36 fields = ('note', 'commentaire')
37 model = recr.CandidatEvaluation
38
39 class EvaluateurForm(forms.Form):
40 evaluateurs = forms.ModelMultipleChoiceField(queryset=
41 recr.Evaluateur.objects.all())
42
43 def __init__(self, *args, **kwargs):
44 self.candidats = kwargs.pop('candidats')
45 super(EvaluateurForm, self).__init__(*args, **kwargs)
46
47 def save(self):
48 for candidat in self.candidats:
49 for evaluateur in self.cleaned_data.get('evaluateurs', []):
50 candidat_evaluation = recr.CandidatEvaluation()
51 candidat_evaluation.candidat = candidat
52 candidat_evaluation.evaluateur = evaluateur
53 candidat_evaluation.save()
54
55 ################################################################################
56 # OFFRE EMPLOI
57 ################################################################################
58 class CandidatPieceForm(emploi.CandidatPieceForm):
59 pass
60
61 class PostulerOffreEmploiForm(emploi.PostulerOffreEmploiForm):
62 pass
63
64 ################################################################################
65 # TEMPLATE COURRIEL
66 ################################################################################
67 class CandidatCourrielTemplateForm(ModelForm):
68 def get_template(self):
69 return self.data['template']
70
71 class Meta:
72 model = recr.CandidatCourriel
73 fields = ('template', )
74
75 class CandidatCourrielForm(ModelForm):
76 def __init__(self, *args, **kwargs):
77 self.candidats = kwargs.pop('candidats')
78 self.template = kwargs.pop('template')
79 super(CandidatCourrielForm, self).__init__(*args, **kwargs)
80
81 def save(self):
82 super(CandidatCourrielForm, self).save()
83
84 class Meta:
85 model = recr.CandidatCourriel
86 fields = ('sujet', 'plain_text', 'html')
87