1 # -=- encoding: utf-8 -=-
3 from django
.db
import models
4 from datamaster_modeles
.models
import Pays
, Implantation
16 class Employe(models
.Model
):
18 id = models
.IntegerField(primary_key
=True)
19 nom
= models
.CharField(max_length
=255)
20 prenom
= models
.CharField(max_length
=255)
21 nationalite
= models
.ForeignKey('datamaster_modeles.Pays', to_field
='code', related_name
='nationalite', db_column
='nationalite')
22 date_naissance
= models
.DateField(null
=True, blank
=True)
24 genre
= models
.CharField(max_length
=1, choices
=GENRE_CHOICES
, null
=True, blank
=True)
25 situation_famille
= models
.CharField(max_length
=1, choices
=SITUATION_CHOICES
, null
=True, blank
=True)
26 date_entree
= models
.DateField(null
=True, blank
=True) #devrait pas être là
28 tel_domicile
= models
.CharField(max_length
=255, null
=True, blank
=True)
29 tel_cellulaire
= models
.CharField(max_length
=255, null
=True, blank
=True)
30 adresse
= models
.CharField(max_length
=255, null
=True, blank
=True)
31 no_rue
= models
.CharField(max_length
=255, null
=True, blank
=True)
32 ville
= models
.CharField(max_length
=255, null
=True, blank
=True)
33 province
= models
.CharField(max_length
=255, null
=True, blank
=True)
34 code_postal
= models
.CharField(max_length
=255, null
=True, blank
=True)
35 pays
= models
.ForeignKey('datamaster_modeles.Pays', to_field
='code', null
=True, blank
=True, related_name
='pays', db_column
='pays')
37 date_creation
= models
.DateField(auto_now_add
=True)
38 date_maj
= models
.DateField(auto_now
=True)
39 commentaire
= models
.TextField(null
=True, blank
=True)
41 def __unicode__(self
):
42 return u
'%s %s' % (self
.prenom
, self
.nom
)
45 TYPE_DOSSIER_CHOICES
= (
50 class DossierManager(models
.Manager
):
52 Chargement de tous les objets FK existants sur chaque QuerySet.
54 def get_query_set(self
):
69 return super(DossierManager
, self
).get_query_set().select_related(*fkeys
).all()
71 class Dossier(models
.Model
):
73 id = models
.IntegerField(primary_key
=True)
74 code
= models
.CharField(max_length
=10, unique
=True)
75 employe
= models
.ForeignKey('Employe', db_column
='employe')
77 poste1
= models
.ForeignKey('Poste', db_column
='poste1', related_name
='poste1')
78 implantation1
= models
.ForeignKey('datamaster_modeles.Implantation', db_column
='implantation1', related_name
='implantation1', blank
=True, null
=True)
79 complement1
= models
.TextField(null
=True, blank
=True)
80 responsable_implantation1
= models
.IntegerField()
81 poste2
= models
.ForeignKey('Poste', db_column
='poste2', related_name
='poste2', blank
=True, null
=True)
82 implantation2
= models
.ForeignKey('datamaster_modeles.Implantation', db_column
='implantation2', related_name
='implantation2', null
=True, blank
=True)
83 complement2
= models
.TextField(null
=True, blank
=True)
84 responsable_implantation2
= models
.IntegerField()
86 service
= models
.ForeignKey('Service', db_column
='service', blank
=True, null
=True)
87 responsable
= models
.ForeignKey('Employe', db_column
='responsable', related_name
='responsable', blank
=True, null
=True)
88 remplacement_de
= models
.ForeignKey('Employe', db_column
='remplacement_de', related_name
='remplacement_de', blank
=True, null
=True)
89 type = models
.CharField(max_length
=1, choices
=TYPE_DOSSIER_CHOICES
)
90 statut
= models
.ForeignKey('Statut', db_column
='statut', blank
=True, null
=True)
91 organisme_bstg
= models
.ForeignKey('OrganismeBstg', db_column
='organisme_bstg', blank
=True, null
=True)
93 classement
= models
.ForeignKey('Classement', db_column
='classement', blank
=True, null
=True)
94 regime_travail
= models
.IntegerField()
96 mandat_date_debut
= models
.DateField()
97 mandat_date_fin
= models
.DateField(null
=True, blank
=True)
99 contrat_date_debut
= models
.DateField()
100 contrat_date_fin
= models
.DateField()
101 type_contrat
= models
.ForeignKey('TypeContrat', db_column
='type_contrat', blank
=True, null
=True)
103 date_creation
= models
.DateField(auto_now_add
=True)
104 date_maj
= models
.DateField(auto_now
=True)
105 commentaire
= models
.TextField(null
=True, blank
=True)
108 objects
= DossierManager()
110 LIEN_PARENTE_CHOICES
= (
111 ('Conjoint', 'Conjoint'),
112 ('Conjointe', 'Conjointe'),
117 class AyantDroit(models
.Model
):
119 id = models
.IntegerField(primary_key
=True)
120 nom
= models
.CharField(max_length
=255)
121 prenom
= models
.CharField(max_length
=255)
123 employe
= models
.ForeignKey('Employe', db_column
='employe', related_name
='employe')
124 lien_parente
= models
.CharField(max_length
=10, choices
=LIEN_PARENTE_CHOICES
, null
=True, blank
=True)
126 commentaire
= models
.TextField(null
=True, blank
=True)
127 actif
= models
.BooleanField()
130 class Remuneration(models
.Model
):
132 id = models
.IntegerField(primary_key
=True)
133 dossier
= models
.ForeignKey('Dossier', db_column
='dossier')
134 type = models
.ForeignKey('TypeRemuneration', db_column
='type')
135 type_revalorisation
= models
.ForeignKey('TypeRevalorisation', db_column
='type_revalorisation', null
=True, blank
=True)
136 montant
= models
.FloatField(null
=True, blank
=True)
137 devise
= models
.ForeignKey('Devise', to_field
='code', db_column
='devise', null
=True, blank
=True)
138 date_effective
= models
.DateField(null
=True, blank
=True)
139 pourcentage
= models
.IntegerField(null
=True, blank
=True)
141 date_creation
= models
.DateField(auto_now_add
=True)
142 user_creation
= models
.IntegerField(null
=True, blank
=True) #User ou employé
143 desactivation
= models
.NullBooleanField(null
=True, blank
=True) #
144 date_desactivation
= models
.DateField(null
=True, blank
=True)
145 user_desactivation
= models
.IntegerField(null
=True, blank
=True) #User ou employé
146 annulation
= models
.NullBooleanField(null
=True, blank
=True)
147 date_annulation
= models
.DateField(null
=True, blank
=True)
148 user_annulation
= models
.IntegerField(null
=True, blank
=True) #User ou employé
150 class FamilleEmploi(models
.Model
):
152 id = models
.IntegerField(primary_key
=True)
153 nom
= models
.CharField(max_length
=255)
155 actif
= models
.BooleanField()
157 class TypePoste(models
.Model
):
159 id = models
.IntegerField(primary_key
=True)
160 nom
= models
.CharField(max_length
=255)
161 nom_feminin
= models
.CharField(max_length
=255)
162 description
= models
.CharField(max_length
=255)
163 is_responsable
= models
.BooleanField()
164 famille_emploi
= models
.ForeignKey('FamilleEmploi', db_column
='famille_emploi')
166 date_modification
= models
.DateField(auto_now
=True)
167 actif
= models
.BooleanField()
169 def __unicode__(self
):
170 return u
'%s' % self
.nom
176 TYPE_PAIEMENT_CHOICES
= (
177 ('Régulier', 'Régulier'),
178 ('Ponctuel', 'Ponctuel'),
181 NATURE_REMUNERATION_CHOICES
= (
182 ('Accessoire', 'Accessoire'),
183 ('Charges', 'Charges'),
184 ('Indemnité', 'Indemnité'),
186 ('Traitement', 'Traitement'),
189 class TypeRemuneration(models
.Model
):
191 id = models
.IntegerField(primary_key
=True)
192 nom
= models
.CharField(max_length
=255)
193 type_paiement
= models
.CharField(max_length
=30, choices
=TYPE_PAIEMENT_CHOICES
)
194 nature_remuneration
= models
.CharField(max_length
=30, choices
=NATURE_REMUNERATION_CHOICES
)
196 actif
= models
.BooleanField()
198 class TypeRevalorisation(models
.Model
):
200 id = models
.IntegerField(primary_key
=True)
201 nom
= models
.CharField(max_length
=255)
203 actif
= models
.BooleanField()
205 PROPORTION_CHOICES
= (
210 class PosteManager(models
.Manager
):
212 Chargement de tous les objets FK existants sur chaque QuerySet.
214 def get_query_set(self
):
219 return super(PosteManager
, self
).get_query_set().select_related(*fkeys
).all()
221 class Poste(models
.Model
):
223 id = models
.IntegerField(primary_key
=True)
224 implantation
= models
.ForeignKey('datamaster_modeles.Implantation',
225 db_column
='implantation', related_name
='+')
226 type_poste
= models
.ForeignKey('TypePoste', db_column
='type_poste')
227 proportion
= models
.CharField(max_length
=10, choices
=PROPORTION_CHOICES
)
228 #(sert à quoi?) renommer "regime_travail" ou autre? convertir data en % (data * 100; ex: 1 = 100%)
230 date_modification
= models
.DateField(auto_now
=True)
231 actif
= models
.BooleanField()
234 objects
= PosteManager()
236 def __unicode__(self
):
237 return u
'%s - %s [%s]' % (self
.implantation
, self
.type_poste
.nom
, self
.id)
240 class Service(models
.Model
):
242 id = models
.IntegerField(primary_key
=True)
243 nom
= models
.CharField(max_length
=255)
245 actif
= models
.BooleanField()
247 def __unicode__(self
):
248 return u
'%s' % self
.nom
254 TYPE_ORGANISME_CHOICES
= (
255 ('MAD', 'Mise à disposition'),
256 ('DET', 'Détachement'),
259 class OrganismeBstg(models
.Model
):
261 id = models
.IntegerField(primary_key
=True)
262 nom
= models
.CharField(max_length
=255)
263 type = models
.CharField(max_length
=10, choices
=TYPE_ORGANISME_CHOICES
)
265 actif
= models
.BooleanField()
267 def __unicode__(self
):
268 return u
'%s (%s)' % (self
.nom
, self
.type)
271 CONTRAT_CATEGORIE_CHOICES
= (
275 class Statut(models
.Model
):
277 id = models
.IntegerField(primary_key
=True)
278 code
= models
.CharField(max_length
=25, unique
=True)
279 nom
= models
.CharField(max_length
=255)
280 type_contrat_categorie
= models
.CharField(max_length
=10, choices
=CONTRAT_CATEGORIE_CHOICES
)
281 #CHOICES A, C (veut dire quoi?) voir TypeContrat.categorie
283 actif
= models
.BooleanField()
285 def __unicode__(self
):
286 return u
'%s' % self
.nom
288 TYPE_CLASSEMENT_CHOICES
= (
292 class Classement(models
.Model
):
294 id = models
.IntegerField(primary_key
=True)
295 type = models
.CharField(max_length
=10, choices
=TYPE_CLASSEMENT_CHOICES
)
296 echelon
= models
.IntegerField()
297 degre
= models
.IntegerField()
298 coefficient
= models
.FloatField()
300 commentaire
= models
.TextField(null
=True, blank
=True)
301 date_modification
= models
.DateField(auto_now
=True)
302 actif
= models
.BooleanField()
304 def __unicode__(self
):
305 return u
'%s.%s.%s (%s)' % (self
.type, self
.echelon
, self
.degre
,
309 class ValeurPoint(models
.Model
):
311 id = models
.IntegerField(primary_key
=True)
312 valeur
= models
.FloatField()
313 implantation
= models
.ForeignKey('datamaster_modeles.Implantation', db_column
='implantation')
315 annee
= models
.IntegerField()
317 def __unicode__(self
):
318 return u
'%s (%s-%s)' % (self
.valeur
, self
.implantation_id
, self
.annee
)
321 ordering
= ['valeur']
324 class TauxChange(models
.Model
):
326 id = models
.IntegerField(primary_key
=True)
327 devise
= models
.ForeignKey('Devise', db_column
='devise')
328 annee
= models
.IntegerField()
329 taux
= models
.FloatField()
331 implantation
= models
.ForeignKey('datamaster_modeles.Implantation', db_column
='implantation')
334 class Devise(models
.Model
):
335 id = models
.IntegerField(primary_key
=True)
336 code
= models
.CharField(max_length
=10, unique
=True)
337 nom
= models
.CharField(max_length
=255)
339 def __unicode__(self
):
340 return u
'%s - %s' % (self
.code
, self
.nom
)
343 class TypeContrat(models
.Model
):
345 id = models
.IntegerField(primary_key
=True)
346 nom
= models
.CharField(max_length
=255)
347 nom_long
= models
.CharField(max_length
=255) #description
348 categorie
= models
.CharField(max_length
=10, choices
=CONTRAT_CATEGORIE_CHOICES
)
350 actif
= models
.BooleanField()
352 def __unicode__(self
):
353 return u
'%s - %s' % (self
.categorie
, self
.nom
)