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 TYPE_DOSSIER_CHOICES
= (
46 class DossierManager(models
.Manager
):
48 Chargement de tous les objets FK existants sur chaque QuerySet.
50 def get_query_set(self
):
65 return super(DossierManager
, self
).get_query_set().select_related(*fkeys
).all()
67 class Dossier(models
.Model
):
69 id = models
.IntegerField(primary_key
=True)
70 code
= models
.CharField(max_length
=10, unique
=True)
71 employe
= models
.ForeignKey('Employe', db_column
='employe')
73 poste1
= models
.ForeignKey('Poste', db_column
='poste1', related_name
='poste1')
74 implantation1
= models
.ForeignKey('datamaster_modeles.Implantation', db_column
='implantation1', related_name
='implantation1')
75 complement1
= models
.TextField(null
=True, blank
=True)
76 responsable_implantation1
= models
.IntegerField()
77 poste2
= models
.ForeignKey('Poste', db_column
='poste2', related_name
='poste2', blank
=True, null
=True)
78 implantation2
= models
.ForeignKey('datamaster_modeles.Implantation', db_column
='implantation2', related_name
='implantation2')
79 complement2
= models
.TextField(null
=True, blank
=True)
80 responsable_implantation2
= models
.IntegerField()
82 service
= models
.ForeignKey('Service', db_column
='service')
83 responsable
= models
.ForeignKey('Employe', db_column
='responsable', related_name
='responsable')
84 remplacement_de
= models
.ForeignKey('Employe', db_column
='remplacement_de', related_name
='remplacement_de')
85 type = models
.CharField(max_length
=1, choices
=TYPE_DOSSIER_CHOICES
)
86 statut
= models
.ForeignKey('Statut', db_column
='statut')
87 organisme_bstg
= models
.ForeignKey('OrganismeBstg', db_column
='organisme_bstg')
89 classement
= models
.ForeignKey('Classement', db_column
='classement')
90 regime_travail
= models
.IntegerField()
92 mandat_date_debut
= models
.DateField()
93 mandat_date_fin
= models
.DateField()
95 contrat_date_debut
= models
.DateField()
96 contrat_date_fin
= models
.DateField()
97 type_contrat
= models
.ForeignKey('TypeContrat', db_column
='type_contrat')
99 date_creation
= models
.DateField(auto_now_add
=True)
100 date_maj
= models
.DateField(auto_now
=True)
101 commentaire
= models
.TextField(null
=True, blank
=True)
104 objects
= DossierManager()
106 LIEN_PARENTE_CHOICES
= (
107 ('Conjoint', 'Conjoint'),
108 ('Conjointe', 'Conjointe'),
113 class AyantDroit(models
.Model
):
115 id = models
.IntegerField(primary_key
=True)
116 nom
= models
.CharField(max_length
=255)
117 prenom
= models
.CharField(max_length
=255)
119 employe
= models
.ForeignKey('Employe', db_column
='employe', related_name
='employe')
120 lien_parente
= models
.CharField(max_length
=10, choices
=LIEN_PARENTE_CHOICES
, null
=True, blank
=True)
122 commentaire
= models
.TextField(null
=True, blank
=True)
123 actif
= models
.BooleanField()
126 class Remuneration(models
.Model
):
128 id = models
.IntegerField(primary_key
=True)
129 dossier
= models
.ForeignKey('Dossier', db_column
='dossier')
130 type = models
.ForeignKey('TypeRemuneration', db_column
='type')
131 type_revalorisation
= models
.ForeignKey('TypeRevalorisation', db_column
='type_revalorisation')
132 montant
= models
.FloatField()
133 devise
= models
.ForeignKey('Devise', to_field
='code', db_column
='devise')
134 date_effective
= models
.DateField()
135 pourcentage
= models
.IntegerField()
137 date_creation
= models
.DateField(auto_now_add
=True)
138 user_creation
= models
.IntegerField() #User ou employé
139 desactivation
= models
.BooleanField() #
140 date_desactivation
= models
.DateField()
141 user_desactivation
= models
.IntegerField() #User ou employé
142 annule
= models
.BooleanField()
143 date_annule
= models
.DateField()
144 user_annule
= models
.IntegerField() #User ou employé
146 class FamilleEmploi(models
.Model
):
148 id = models
.IntegerField(primary_key
=True)
149 nom
= models
.CharField(max_length
=255)
151 actif
= models
.BooleanField()
153 class TypePoste(models
.Model
):
155 id = models
.IntegerField(primary_key
=True)
156 nom
= models
.CharField(max_length
=255)
157 nom_feminin
= models
.CharField(max_length
=255)
158 description
= models
.CharField(max_length
=255)
159 is_responsable
= models
.BooleanField()
160 famille_emploi
= models
.ForeignKey('FamilleEmploi', db_column
='famille_emploi')
162 date_modification
= models
.DateField(auto_now
=True)
163 actif
= models
.BooleanField()
165 def __unicode__(self
):
166 return u
'%s' % self
.nom
169 TYPE_PAIEMENT_CHOICES
= (
170 ('Régulier', 'Régulier'),
171 ('Ponctuel', 'Ponctuel'),
174 NATURE_REMUNERATION_CHOICES
= (
175 ('Accessoire', 'Accessoire'),
176 ('Charges', 'Charges'),
177 ('Indemnité', 'Indemnité'),
179 ('Traitement', 'Traitement'),
182 class TypeRemuneration(models
.Model
):
184 id = models
.IntegerField(primary_key
=True)
185 nom
= models
.CharField(max_length
=255)
186 type_paiement
= models
.CharField(max_length
=30, choices
=TYPE_PAIEMENT_CHOICES
)
187 nature_remuneration
= models
.CharField(max_length
=30, choices
=NATURE_REMUNERATION_CHOICES
)
189 actif
= models
.BooleanField()
191 class TypeRevalorisation(models
.Model
):
193 id = models
.IntegerField(primary_key
=True)
194 nom
= models
.CharField(max_length
=255)
196 actif
= models
.BooleanField()
198 PROPORTION_CHOICES
= (
203 class PosteManager(models
.Manager
):
205 Chargement de tous les objets FK existants sur chaque QuerySet.
207 def get_query_set(self
):
212 return super(PosteManager
, self
).get_query_set().select_related(*fkeys
).all()
214 class Poste(models
.Model
):
216 id = models
.IntegerField(primary_key
=True)
217 implantation
= models
.ForeignKey('datamaster_modeles.Implantation',
218 db_column
='implantation', related_name
='+')
219 type_poste
= models
.ForeignKey('TypePoste', db_column
='type_poste')
220 proportion
= models
.CharField(max_length
=10, choices
=PROPORTION_CHOICES
)
221 #(sert à quoi?) renommer "regime_travail" ou autre? convertir data en % (data * 100; ex: 1 = 100%)
223 date_modification
= models
.DateField(auto_now
=True)
224 actif
= models
.BooleanField()
227 objects
= PosteManager()
229 def __unicode__(self
):
230 return u
'%s - %s' % (self
.implantation
, self
.type_poste
.nom
)
233 class Service(models
.Model
):
235 id = models
.IntegerField(primary_key
=True)
236 nom
= models
.CharField(max_length
=255)
238 actif
= models
.BooleanField()
240 def __unicode__(self
):
241 return u
'%s' % self
.nom
244 TYPE_ORGANISME_CHOICES
= (
245 ('MAD', 'Mise à disposition'),
246 ('DET', 'Détachement'),
249 class OrganismeBstg(models
.Model
):
251 id = models
.IntegerField(primary_key
=True)
252 nom
= models
.CharField(max_length
=255)
253 type = models
.CharField(max_length
=10, choices
=TYPE_ORGANISME_CHOICES
)
255 actif
= models
.BooleanField()
257 CONTRAT_CATEGORIE_CHOICES
= (
261 class Statut(models
.Model
):
263 id = models
.IntegerField(primary_key
=True)
264 code
= models
.CharField(max_length
=25, unique
=True)
265 nom
= models
.CharField(max_length
=255)
266 type_contrat_categorie
= models
.CharField(max_length
=10, choices
=CONTRAT_CATEGORIE_CHOICES
)
267 #CHOICES A, C (veut dire quoi?) voir TypeContrat.categorie
269 actif
= models
.BooleanField()
271 TYPE_CLASSEMENT_CHOICES
= (
275 class Classement(models
.Model
):
277 id = models
.IntegerField(primary_key
=True)
278 type = models
.CharField(max_length
=10, choices
=TYPE_CLASSEMENT_CHOICES
)
279 echelon
= models
.IntegerField()
280 degre
= models
.IntegerField()
281 coefficient
= models
.FloatField()
283 commentaire
= models
.TextField(null
=True, blank
=True)
284 date_modification
= models
.DateField(auto_now
=True)
285 actif
= models
.BooleanField()
287 def __unicode__(self
):
288 return u
'%s.%s.%s (%s)' % (self
.type, self
.echelon
, self
.degre
,
292 class ValeurPoint(models
.Model
):
294 id = models
.IntegerField(primary_key
=True)
295 valeur
= models
.FloatField()
296 implantation
= models
.ForeignKey('datamaster_modeles.Implantation', db_column
='implantation')
298 annee
= models
.IntegerField()
300 def __unicode__(self
):
301 return u
'%s (%s-%s)' % (self
.valeur
, self
.implantation_id
, self
.annee
)
304 class TauxChange(models
.Model
):
306 id = models
.IntegerField(primary_key
=True)
307 devise
= models
.ForeignKey('Devise', to_field
='code', db_column
='devise')
308 annee
= models
.IntegerField()
309 taux
= models
.FloatField()
311 implantation
= models
.ForeignKey('datamaster_modeles.Implantation', db_column
='implantation')
314 class Devise(models
.Model
):
315 id = models
.IntegerField(primary_key
=True)
316 code
= models
.CharField(max_length
=10, unique
=True)
317 nom
= models
.CharField(max_length
=255)
319 def __unicode__(self
):
320 return u
'%s - %s' % (self
.code
, self
.nom
)
323 class TypeContrat(models
.Model
):
325 id = models
.IntegerField(primary_key
=True)
326 nom
= models
.CharField(max_length
=255)
327 nom_long
= models
.CharField(max_length
=255) #description
328 categorie
= models
.CharField(max_length
=10, choices
=CONTRAT_CATEGORIE_CHOICES
)
330 actif
= models
.BooleanField()