df59fcab |
1 | # -=- encoding: utf-8 -=- |
2 | |
3 | import datetime |
4 | |
4418c732 |
5 | from django.core.files.storage import FileSystemStorage |
6f2d5d58 |
6 | from django.db import models |
4418c732 |
7 | import settings |
6f2d5d58 |
8 | |
df59fcab |
9 | import datamaster_modeles.models as ref |
10 | from project.rh import models as rh |
11 | |
12 | |
13 | # Abstracts |
14 | class Metadata(models.Model): |
15 | """Méta-données AUF. |
16 | Metadata.actif = flag remplaçant la suppression. |
17 | actif == False : objet réputé supprimé. |
18 | """ |
19 | actif = models.BooleanField(default=True) |
20 | date_creation = models.DateField(auto_now_add=True) |
21 | |
22 | class Meta: |
23 | abstract = True |
24 | |
25 | |
26 | class OffreEmploi(Metadata): |
4418c732 |
27 | # TODO : Afficher les bureaux selon la région choisies? |
df59fcab |
28 | nom = models.CharField(max_length=255) |
29 | resume = models.TextField() |
30 | description = models.TextField() |
31 | poste = models.ForeignKey(rh.Poste, db_column='poste') |
32 | date_limite = models.DateField(verbose_name="Date limite") |
33 | region = models.ForeignKey(ref.Region, db_column='region') |
34 | bureau = models.ForeignKey(ref.Bureau, db_column='bureau') |
4418c732 |
35 | |
36 | def __unicode__(self): |
37 | return '%s [%s]' % (self.nom, self.id) |
df59fcab |
38 | |
39 | |
40 | ### CANDIDAT |
41 | |
42 | GENRE_CHOICES = ( |
43 | ('M', 'Homme'), |
44 | ('F', 'Femme'), |
45 | ) |
46 | SITUATION_CHOICES = ( |
47 | ('C', 'Célibataire'), |
48 | ('F', 'Fiancé'), |
49 | ('M', 'Marié'), |
50 | ('D', 'Divorcé'), |
51 | ) |
52 | STATUT_CHOICES = ( |
53 | ('NOUV', 'Nouveau'), |
54 | ('REF', 'Refusé'), |
55 | ('SEL', 'Sélectionné'), |
56 | ('ACC', 'Accepté'), |
57 | ('REC', 'Recevable'), # Trouver une lettre plus appropriée? |
58 | ) |
59 | |
60 | class Candidat(Metadata): |
7f9e891e |
61 | # TODO : Automatiser le statut à la création à Nouveau |
62 | statut = models.CharField(max_length=4, |
63 | choices=STATUT_CHOICES) |
df59fcab |
64 | offre_emploi = models.ForeignKey('OffreEmploi', db_column='offre_emploi', |
7f9e891e |
65 | related_name='+') |
df59fcab |
66 | prenom = models.CharField(max_length=255) |
67 | nom = models.CharField(max_length=255) |
68 | genre = models.CharField(max_length=1, choices=GENRE_CHOICES) |
69 | nationalite = models.ForeignKey(ref.Pays, |
4418c732 |
70 | db_column='nationalite', |
7f9e891e |
71 | related_name='+') |
df59fcab |
72 | date_naissance = models.DateField(verbose_name="Date de naissance") |
73 | situation_famille = models.CharField(max_length=1, |
4418c732 |
74 | choices=SITUATION_CHOICES) |
df59fcab |
75 | nombre_dependant = models.IntegerField(verbose_name="Nombre de dépendant") |
76 | niveau_diplome = models.CharField(max_length=255, |
4418c732 |
77 | verbose_name="Niveau du diplôme") |
df59fcab |
78 | employeur_actuel = models.CharField(max_length=255) |
79 | poste_actuel = models.CharField(max_length=255) |
80 | domaine_professionnel = models.CharField(max_length=255) |
81 | |
82 | # Adresse |
83 | adresse = models.CharField(max_length=255) |
84 | ville = models.CharField(max_length=255) |
85 | etat_province = models.CharField(max_length=255, |
4418c732 |
86 | verbose_name="État/Province") |
df59fcab |
87 | pays = models.ForeignKey(ref.Pays, db_column='pays', |
7f9e891e |
88 | related_name='+') |
4418c732 |
89 | |
90 | def __unicode__(self): |
91 | return '%s %s [%s]' % (self.prenom, self.nom, self.id) |
92 | |
93 | ### PIECE CANDIDAT |
94 | # Upload de fichiers |
95 | storage_prive = FileSystemStorage(settings.PRIVE_MEDIA_ROOT, |
96 | base_url=settings.PRIVE_MEDIA_URL) |
97 | |
98 | def candidat_piece_dispatch(instance, filename): |
99 | path = "offre_emploi/%s_%s/%s/%s_%s" % (instance.candidat.nom, |
100 | instance.candidat.prenom, instance.nom, instance.candidat.id, |
101 | filename) |
102 | return path |
103 | |
104 | class CandidatPiece(models.Model): |
105 | candidat = models.ForeignKey(Candidat, db_column='candidat', |
106 | related_name='+') |
107 | nom = models.CharField(max_length=255) |
108 | path = models.FileField(upload_to=candidat_piece_dispatch, |
109 | storage=storage_prive) |
110 | |
111 | def __unicode__(self): |
112 | return '%s' % (self.nom) |
113 | |
114 | class Evaluateur(models.Model): |
115 | candidats = models.ManyToManyField(Candidat) |
116 | |
117 | class CandidatEvaluation(models.Model): |
118 | candidat = models.ForeignKey(Candidat, db_column='candidat', |
7f9e891e |
119 | related_name='+') |
4418c732 |
120 | evaluateur = models.ForeignKey(Evaluateur, db_column='evaluateur', |
7f9e891e |
121 | related_name='+') |
4418c732 |
122 | note = models.IntegerField() |
123 | commentaire = models.TextField() |
124 | date = models.DateField(auto_now_add=True) |