Changement du verbose_name de CandidatPiece
[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
6f2d5d58 6from django.db import models
4418c732 7import settings
362a3534 8#from private_files import PrivateFileField
6f2d5d58 9
df59fcab 10import datamaster_modeles.models as ref
11from project.rh import models as rh
12
596fe324 13### CONSTANTES
14#NOTES
15NOTE_MIN = 1
16NOTE_RANGE = 1
17NOTE_MAX = 10
18NOTES = [(i, i) for i in range(NOTE_MIN, NOTE_MAX, NOTE_RANGE)]
19
df59fcab 20# Abstracts
21class Metadata(models.Model):
22 """Méta-données AUF.
23 Metadata.actif = flag remplaçant la suppression.
24 actif == False : objet réputé supprimé.
25 """
26 actif = models.BooleanField(default=True)
27 date_creation = models.DateField(auto_now_add=True)
28
29 class Meta:
30 abstract = True
31
4e8e178f 32class OffreEmploiManager(models.Manager):
33 def get_query_set(self):
61a4b478 34 fkeys = ('region',)
4e8e178f 35 return super(OffreEmploiManager, self).get_query_set().select_related(*fkeys).all()
36
37class ProxyPoste(rh.Poste):
38 class Meta:
39 proxy = True
40
41 def __unicode__(self):
42 return '%s [%s]' % (self.nom, self.id)
df59fcab 43
44class OffreEmploi(Metadata):
4e8e178f 45 objects = OffreEmploiManager()
df59fcab 46 nom = models.CharField(max_length=255)
b235ec9d 47 resume = models.TextField(verbose_name="Résumé")
df59fcab 48 description = models.TextField()
61a4b478 49 poste = models.ForeignKey(ProxyPoste, db_column='poste')#)
df59fcab 50 date_limite = models.DateField(verbose_name="Date limite")
b235ec9d 51 region = models.ForeignKey(ref.Region, db_column='region',
52 verbose_name="Région")
53 bureau = models.ForeignKey(ref.Bureau, db_column='bureau', )
54
55 class Meta:
56 verbose_name_plural = "offres d'emploi"
4418c732 57
58 def __unicode__(self):
59 return '%s [%s]' % (self.nom, self.id)
df59fcab 60
61
62### CANDIDAT
63
64GENRE_CHOICES = (
65 ('M', 'Homme'),
66 ('F', 'Femme'),
67)
68SITUATION_CHOICES = (
69 ('C', 'Célibataire'),
70 ('F', 'Fiancé'),
71 ('M', 'Marié'),
72 ('D', 'Divorcé'),
73)
74STATUT_CHOICES = (
75 ('NOUV', 'Nouveau'),
76 ('REF', 'Refusé'),
77 ('SEL', 'Sélectionné'),
78 ('ACC', 'Accepté'),
79 ('REC', 'Recevable'), # Trouver une lettre plus appropriée?
80)
81
b235ec9d 82class Candidat(Metadata):
8ea41642 83 statut = models.CharField(max_length=4, choices=STATUT_CHOICES,
84 default='NOUV')
df59fcab 85 offre_emploi = models.ForeignKey('OffreEmploi', db_column='offre_emploi',
7f9e891e 86 related_name='+')
df59fcab 87 prenom = models.CharField(max_length=255)
88 nom = models.CharField(max_length=255)
89 genre = models.CharField(max_length=1, choices=GENRE_CHOICES)
90 nationalite = models.ForeignKey(ref.Pays,
4418c732 91 db_column='nationalite',
7f9e891e 92 related_name='+')
df59fcab 93 date_naissance = models.DateField(verbose_name="Date de naissance")
94 situation_famille = models.CharField(max_length=1,
4418c732 95 choices=SITUATION_CHOICES)
df59fcab 96 nombre_dependant = models.IntegerField(verbose_name="Nombre de dépendant")
97 niveau_diplome = models.CharField(max_length=255,
4418c732 98 verbose_name="Niveau du diplôme")
df59fcab 99 employeur_actuel = models.CharField(max_length=255)
100 poste_actuel = models.CharField(max_length=255)
101 domaine_professionnel = models.CharField(max_length=255)
102
103 # Adresse
104 adresse = models.CharField(max_length=255)
105 ville = models.CharField(max_length=255)
106 etat_province = models.CharField(max_length=255,
4418c732 107 verbose_name="État/Province")
df59fcab 108 pays = models.ForeignKey(ref.Pays, db_column='pays',
7f9e891e 109 related_name='+')
4418c732 110
111 def __unicode__(self):
112 return '%s %s [%s]' % (self.prenom, self.nom, self.id)
113
114### PIECE CANDIDAT
115# Upload de fichiers
116storage_prive = FileSystemStorage(settings.PRIVE_MEDIA_ROOT,
117 base_url=settings.PRIVE_MEDIA_URL)
118
119def candidat_piece_dispatch(instance, filename):
120 path = "offre_emploi/%s_%s/%s/%s_%s" % (instance.candidat.nom,
121 instance.candidat.prenom, instance.nom, instance.candidat.id,
122 filename)
123 return path
124
125class CandidatPiece(models.Model):
126 candidat = models.ForeignKey(Candidat, db_column='candidat',
2b3edf33 127 related_name='candidat_piece')
4418c732 128 nom = models.CharField(max_length=255)
362a3534 129 #path = PrivateFileField("file", upload_to=candidat_piece_dispatch)
f6749f29 130 path = models.FileField(verbose_name="Fichier",
131 upload_to=candidat_piece_dispatch,
2b3edf33 132 storage=storage_prive, )
4418c732 133
b235ec9d 134 class Meta:
12767731 135 verbose_name = "pièce jointe"
136 verbose_name_plural = "pièces jointes"
b235ec9d 137
4418c732 138 def __unicode__(self):
139 return '%s' % (self.nom)
140
f6749f29 141class UserProfile(models.Model):
b235ec9d 142 user = models.ForeignKey("auth.User", unique=True,
143 verbose_name="Permission")
2adf9e0c 144 candidats = models.ManyToManyField(Candidat, verbose_name='Candidats',
145 blank=True, null=True,related_name="evaluateurs")
3b4bfad3 146 regions = models.ManyToManyField(ref.Region,
147 verbose_name="Régions", )
eb579d40 148
b235ec9d 149 class Meta:
150 verbose_name = "permission"
151
2adf9e0c 152 def __unicode__(self):
153 return '%s %s' % (self.user.first_name, self.user.last_name)
154
f6749f29 155UserProfile.profile = property(lambda u: UserProfile.objects.get_or_create(user=u)[0])
4418c732 156
157class CandidatEvaluation(models.Model):
158 candidat = models.ForeignKey(Candidat, db_column='candidat',
7f9e891e 159 related_name='+')
f6749f29 160 evaluateur = models.ForeignKey(UserProfile, db_column='evaluateur',
b235ec9d 161 related_name='+', verbose_name="Évaluateur")
596fe324 162 note = models.IntegerField(choices=NOTES, blank=True, null=True)
362a3534 163 commentaire = models.TextField(null=True, blank=True)
4418c732 164 date = models.DateField(auto_now_add=True)
b235ec9d 165
166 class Meta:
167 verbose_name = "évaluation du candidat"
168 verbose_name_plural = "évaluations des candidats"