Retrait de la vue evaluer_candidat
[auf_rh_dae.git] / project / recrutement / models.py
CommitLineData
df59fcab 1# -=- encoding: utf-8 -=-
2
3import datetime
b235ec9d 4from django.contrib.auth.models import User
4418c732 5from django.core.files.storage import FileSystemStorage
ec517164 6from tinymce import models as tinymce_models
6f2d5d58 7from django.db import models
4418c732 8import settings
362a3534 9#from private_files import PrivateFileField
6f2d5d58 10
df59fcab 11import datamaster_modeles.models as ref
d0a50c0a 12from project.rh.models import Poste
df59fcab 13
596fe324 14### CONSTANTES
15#NOTES
16NOTE_MIN = 1
17NOTE_RANGE = 1
e34a2ae0 18NOTE_MAX = 11
596fe324 19NOTES = [(i, i) for i in range(NOTE_MIN, NOTE_MAX, NOTE_RANGE)]
ee42ad96 20HELP_TEXT_NB_DEPENDANT = "Le nombre de personnes à charge"
596fe324 21
df59fcab 22# Abstracts
23class Metadata(models.Model):
24 """Méta-données AUF.
25 Metadata.actif = flag remplaçant la suppression.
26 actif == False : objet réputé supprimé.
27 """
28 actif = models.BooleanField(default=True)
29 date_creation = models.DateField(auto_now_add=True)
30
31 class Meta:
32 abstract = True
33
4e8e178f 34class OffreEmploiManager(models.Manager):
35 def get_query_set(self):
61a4b478 36 fkeys = ('region',)
720c3ad5
NBV
37 return super(OffreEmploiManager, self).get_query_set().\
38 select_related(*fkeys).all()
4e8e178f 39
47cf4908 40class ProxyPoste(Poste):
4e8e178f 41 class Meta:
42 proxy = True
43
44 def __unicode__(self):
45 return '%s [%s]' % (self.nom, self.id)
df59fcab 46
47class OffreEmploi(Metadata):
27c81d11 48 #objects = OffreEmploiManager()
df59fcab 49 nom = models.CharField(max_length=255)
b235ec9d 50 resume = models.TextField(verbose_name="Résumé")
ec517164 51 description = tinymce_models.HTMLField()
52 poste = models.ForeignKey(ProxyPoste, db_column='poste')
df59fcab 53 date_limite = models.DateField(verbose_name="Date limite")
b235ec9d 54 region = models.ForeignKey(ref.Region, db_column='region',
55 verbose_name="Région")
56 bureau = models.ForeignKey(ref.Bureau, db_column='bureau', )
ec517164 57 duree_affectation = models.CharField(max_length=255,
58 verbose_name="Durée de l'affectation")
59 renumeration = models.CharField(max_length=255,
60 verbose_name='Rénumération')
61 debut_affectation = models.DateField(verbose_name="Début de l'affectation")
62 lieu_affectation = models.ForeignKey(ref.Implantation,
63 db_column='implantation',
64 verbose_name="Lieu d'affectation")
b235ec9d 65
66 class Meta:
67 verbose_name_plural = "offres d'emploi"
4418c732 68
69 def __unicode__(self):
70 return '%s [%s]' % (self.nom, self.id)
df59fcab 71
f6724c20
NBV
72class ProxyOffreEmploi(OffreEmploi):
73 class Meta:
74 proxy = True
75 verbose_name = "Offre d'emploi (visualisation)"
76 verbose_name_plural = "Offres d'emploi (visualisation)"
77
78 def __unicode__(self):
79 return '%s [%s] - View' % (self.nom, self.id)
df59fcab 80
81### CANDIDAT
82
83GENRE_CHOICES = (
84 ('M', 'Homme'),
85 ('F', 'Femme'),
86)
87SITUATION_CHOICES = (
88 ('C', 'Célibataire'),
89 ('F', 'Fiancé'),
90 ('M', 'Marié'),
91 ('D', 'Divorcé'),
92)
93STATUT_CHOICES = (
94 ('NOUV', 'Nouveau'),
65c4cbd9 95 ('REC', 'Recevable'),
df59fcab 96 ('SEL', 'Sélectionné'),
65c4cbd9 97 ('REF', 'Refusé'),
df59fcab 98 ('ACC', 'Accepté'),
df59fcab 99)
100
b235ec9d 101class Candidat(Metadata):
8ea41642 102 statut = models.CharField(max_length=4, choices=STATUT_CHOICES,
103 default='NOUV')
df59fcab 104 offre_emploi = models.ForeignKey('OffreEmploi', db_column='offre_emploi',
7f9e891e 105 related_name='+')
3b4b948e 106 prenom = models.CharField(max_length=255, verbose_name='Prénom', )
df59fcab 107 nom = models.CharField(max_length=255)
108 genre = models.CharField(max_length=1, choices=GENRE_CHOICES)
109 nationalite = models.ForeignKey(ref.Pays,
3b4b948e 110 db_column='nationalite', related_name='+',
111 verbose_name='Nationalité')
ee42ad96 112 date_naissance = models.DateField(verbose_name='Date de naissance')
df59fcab 113 situation_famille = models.CharField(max_length=1,
ec517164 114 choices=SITUATION_CHOICES,
115 verbose_name='Situation familiale')
ee42ad96 116 nombre_dependant = models.IntegerField(verbose_name='Nombre de dépendant',
117 help_text=HELP_TEXT_NB_DEPENDANT)
df59fcab 118 niveau_diplome = models.CharField(max_length=255,
3b4b948e 119 verbose_name='Niveau du diplôme')
df59fcab 120 employeur_actuel = models.CharField(max_length=255)
121 poste_actuel = models.CharField(max_length=255)
122 domaine_professionnel = models.CharField(max_length=255)
ec517164 123 telephone = models.CharField(max_length=255, verbose_name='Téléphone', )
124 email = models.EmailField(max_length=255, verbose_name = 'Courriel', )
df59fcab 125
126 # Adresse
127 adresse = models.CharField(max_length=255)
128 ville = models.CharField(max_length=255)
129 etat_province = models.CharField(max_length=255,
4418c732 130 verbose_name="État/Province")
ec517164 131 code_postal = models.CharField(max_length=255, blank=True)
df59fcab 132 pays = models.ForeignKey(ref.Pays, db_column='pays',
7f9e891e 133 related_name='+')
4418c732 134
135 def __unicode__(self):
136 return '%s %s [%s]' % (self.prenom, self.nom, self.id)
137
f6724c20
NBV
138class ProxyCandidat(Candidat):
139 class Meta:
140 proxy = True
141 verbose_name = "Candidat (visualisation)"
142 verbose_name_plural = "Candidats (visualisation)"
143
144 def __unicode__(self):
145 return '%s %s [%s]' % (self.prenom, self.nom, self.id)
146
4418c732 147### PIECE CANDIDAT
ee42ad96 148
149TYPE_PIECE_CHOICES = (
150 ('CV','CV'),
151 ('LET','Lettre'),
152 ('AUT','Autre'),
153)
4418c732 154# Upload de fichiers
155storage_prive = FileSystemStorage(settings.PRIVE_MEDIA_ROOT,
156 base_url=settings.PRIVE_MEDIA_URL)
157
158def candidat_piece_dispatch(instance, filename):
159 path = "offre_emploi/%s_%s/%s/%s_%s" % (instance.candidat.nom,
160 instance.candidat.prenom, instance.nom, instance.candidat.id,
161 filename)
162 return path
163
164class CandidatPiece(models.Model):
165 candidat = models.ForeignKey(Candidat, db_column='candidat',
2b3edf33 166 related_name='candidat_piece')
ee42ad96 167 nom = models.CharField(max_length=3, choices=TYPE_PIECE_CHOICES)
362a3534 168 #path = PrivateFileField("file", upload_to=candidat_piece_dispatch)
f6749f29 169 path = models.FileField(verbose_name="Fichier",
170 upload_to=candidat_piece_dispatch,
2b3edf33 171 storage=storage_prive, )
4418c732 172
b235ec9d 173 class Meta:
12767731 174 verbose_name = "pièce jointe"
175 verbose_name_plural = "pièces jointes"
b235ec9d 176
4418c732 177 def __unicode__(self):
178 return '%s' % (self.nom)
179
4e8340cf 180class Evaluateur(models.Model):
720c3ad5
NBV
181 user = models.ForeignKey(User, unique=True, verbose_name="permission")
182 candidats = models.ManyToManyField(Candidat, through='CandidatEvaluation',
183 #verbose_name='candidats', blank=True, null=True,
184 related_name="evaluateurs")
4e8340cf 185
186 class Meta:
187 verbose_name = "évaluateur"
188
189 def __unicode__(self):
190 return '%s %s' % (self.user.first_name, self.user.last_name)
191
b89fef74 192class AdministrateurRegional(models.Model):
27c81d11 193 user = models.ForeignKey(User, unique=True,
4e8340cf 194 verbose_name="permission")
3b4bfad3 195 regions = models.ManyToManyField(ref.Region,
196 verbose_name="Régions", )
eb579d40 197
b235ec9d 198 class Meta:
27c81d11 199 verbose_name = "administrateur régional"
4e8340cf 200 verbose_name_plural = "administrateurs régionaux"
b235ec9d 201
2adf9e0c 202 def __unicode__(self):
203 return '%s %s' % (self.user.first_name, self.user.last_name)
204
4418c732 205class CandidatEvaluation(models.Model):
206 candidat = models.ForeignKey(Candidat, db_column='candidat',
3b4b948e 207 related_name='+',)
27c81d11 208 evaluateur = models.ForeignKey(Evaluateur, db_column='evaluateur',
cced6a23 209 related_name='+', verbose_name='Évaluateur')
596fe324 210 note = models.IntegerField(choices=NOTES, blank=True, null=True)
362a3534 211 commentaire = models.TextField(null=True, blank=True)
4418c732 212 date = models.DateField(auto_now_add=True)
b235ec9d 213
214 class Meta:
cced6a23 215 verbose_name = 'évaluation du candidat'
216 verbose_name_plural = 'évaluations des candidats'
ec517164 217
1df9fc7f 218#### TEMPLATE COURRIEL
d84c3a68 219TEMPLATE_CHOICES = (
220 ('SEL', 'Sélectionné'),
221 ('REF', 'Refusé'),
222)
223
224class CourrielTemplate(models.Model):
0b1bbb53 225 nom_modele = models.CharField(max_length=100, verbose_name='Nom modèle', )
226 sujet = models.CharField(max_length=100, )
227 plain_text = models.TextField(verbose_name='Texte', )
228 html = tinymce_models.HTMLField(verbose_name='Texte HTML', )
d84c3a68 229
230 def __unicode__(self):
0b1bbb53 231 return u'%s' % self.nom_modele
d84c3a68 232
233 class Meta:
0b1bbb53 234 ordering = ['nom_modele',]
d84c3a68 235
236class CandidatCourriel(models.Model):
ec517164 237 candidat = models.ForeignKey(Candidat, db_column='candidat',
d84c3a68 238 related_name='+', )
0b1bbb53 239 template = models.ForeignKey(CourrielTemplate, db_column='nom',
240 related_name='+', verbose_name="Modèle de courriel", )
ec517164 241 titre = models.CharField(max_length=255, )
d84c3a68 242 texte = models.TextField(null=True, blank=True, )
ec517164 243
244 def __unicode__(self):
245 return '%s' % (self.titre)
ec517164 246