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