1 # -=- encoding: utf-8 -=-
3 from django
.db
import models
5 from auf
.django
.references
.managedref
import models
as managedref
7 class Employe(models
.Model
):
8 """Personne en contrat d'employé (CDD ou CDI) à l'AUF
10 id = models
.IntegerField(primary_key
=True)
11 nom
= models
.CharField(max_length
=255)
12 prenom
= models
.CharField(max_length
=255)
13 implantation
= models
.ForeignKey(to
='Implantation', db_column
='implantation', related_name
='lieu_travail_theorique_de') # SGRH
14 implantation_physique
= models
.ForeignKey(to
='Implantation', db_column
='implantation_physique', related_name
='lieu_travail_reel_de')
15 courriel
= models
.CharField(max_length
=255, null
=True, blank
=True)
16 genre
= models
.CharField(max_length
=3)
17 fonction
= models
.CharField(max_length
=255, null
=True, blank
=True)
18 telephone_poste
= models
.CharField(max_length
=255, null
=True, blank
=True)
19 telephone_ip
= models
.CharField(max_length
=255, null
=True, blank
=True)
20 responsable
= models
.ForeignKey(to
='Employe', db_column
='responsable', related_name
='responsable_de', null
=True, blank
=True)
21 mandat_debut
= models
.DateField(null
=True, blank
=True)
22 mandat_fin
= models
.DateField(null
=True, blank
=True)
23 date_entree
= models
.DateField(null
=True, blank
=True)
24 service
= models
.ForeignKey('Service', db_column
='service')
25 poste_type_1
= models
.ForeignKey('PosteType', null
=True, blank
=True, db_column
='poste_type_1', related_name
='poste_type_1')
26 poste_type_2
= models
.ForeignKey('PosteType', null
=True, blank
=True, db_column
='poste_type_2', related_name
='poste_type_2')
28 actif
= models
.BooleanField()
31 db_table
= u
'ref_employe'
35 def __unicode__(self
):
36 return u
"%s, %s [%d]" % (self
.nom
, self
.prenom
, self
.id)
38 class Authentification(models
.Model
):
39 """Authentification"""
40 id = models
.ForeignKey('Employe', primary_key
=True, db_column
='id')
41 courriel
= models
.CharField(max_length
=255, unique
=True)
42 motdepasse
= models
.CharField(max_length
=255)
43 actif
= models
.BooleanField()
46 db_table
= u
'ref_authentification'
50 def __unicode__(self
):
51 return u
"%s [%d]" % (self
.courriel
, self
.id)
53 class Service(models
.Model
):
54 """Services (donnée de référence, source: SGRH).
56 id = models
.IntegerField(primary_key
=True)
57 nom
= models
.CharField(max_length
=255)
58 actif
= models
.BooleanField()
61 db_table
= u
'ref_service'
65 def __unicode__(self
):
66 return "%s (%s)" % (self
.nom
, self
.id)
68 class PosteType(models
.Model
):
69 """Postes types (donnée de référence, source: SGRH).
71 id = models
.IntegerField(primary_key
=True)
72 nom
= models
.CharField(max_length
=255)
73 actif
= models
.BooleanField()
76 db_table
= u
'ref_poste_type'
79 def __unicode__(self
):
80 return "%s (%s)" % (self
.nom
, self
.id)
82 class GroupeArh(models
.Model
):
83 id = models
.AutoField(primary_key
=True)
84 employe
= models
.ForeignKey('Employe', db_column
='employe')
85 actif
= models
.BooleanField()
88 db_table
= u
'ref_groupe_arh'
91 class GroupeDirRegion(models
.Model
):
92 id = models
.AutoField(primary_key
=True)
93 employe
= models
.ForeignKey('Employe', db_column
='employe')
94 region
= models
.ForeignKey('Region', db_column
='region')
95 actif
= models
.BooleanField()
98 db_table
= u
'ref_groupe_dir_region'
101 class GroupeAdmRegion(models
.Model
):
102 id = models
.AutoField(primary_key
=True)
103 employe
= models
.ForeignKey('Employe', db_column
='employe')
104 region
= models
.ForeignKey('Region', db_column
='region')
105 actif
= models
.BooleanField()
108 db_table
= u
'ref_groupe_adm_region'
111 class GroupeRespImplantation(models
.Model
):
112 id = models
.AutoField(primary_key
=True)
113 employe
= models
.ForeignKey('Employe', db_column
='employe')
114 implantation
= models
.ForeignKey('Implantation', db_column
='implantation')
115 type = models
.CharField(max_length
=255, blank
=True, null
=True)
116 actif
= models
.BooleanField()
119 db_table
= u
'ref_groupe_resp_implantation'
122 class GroupeDirProgramme(models
.Model
):
123 id = models
.AutoField(primary_key
=True)
124 employe
= models
.ForeignKey('Employe', db_column
='employe')
125 service
= models
.ForeignKey('Service', db_column
='service')
126 actif
= models
.BooleanField()
129 db_table
= u
'ref_groupe_dir_programme'
132 class GroupeDirDelegProgrammeReg(models
.Model
):
133 id = models
.AutoField(primary_key
=True)
134 employe
= models
.ForeignKey('Employe', db_column
='employe')
135 region
= models
.ForeignKey('Region', db_column
='region')
136 actif
= models
.BooleanField()
139 db_table
= u
'ref_groupe_dir_deleg_programme_reg'
142 class GroupeComptable(models
.Model
):
143 id = models
.AutoField(primary_key
=True)
144 employe
= models
.ForeignKey('Employe', db_column
='employe')
145 actif
= models
.BooleanField()
148 db_table
= u
'ref_groupe_comptable'
151 class GroupeComptableRegional(models
.Model
):
152 id = models
.AutoField(primary_key
=True)
153 employe
= models
.ForeignKey('Employe', db_column
='employe')
154 actif
= models
.BooleanField()
157 db_table
= u
'ref_groupe_comptable_regional'
160 class GroupeComptableLocal(models
.Model
):
161 id = models
.AutoField(primary_key
=True)
162 employe
= models
.ForeignKey('Employe', db_column
='employe')
163 actif
= models
.BooleanField()
166 db_table
= u
'ref_groupe_comptable_local'
169 class Discipline(models
.Model
):
170 """ ATTENTION: DÉSUET
171 Discipline (donnée de référence, source: SQI).
172 Une discipline est une catégorie de savoirs scientifiques.
173 Le conseil scientifique fixe la liste des disciplines.
176 id = models
.IntegerField(primary_key
=True)
177 code
= models
.CharField(max_length
=255, unique
=True)
178 nom
= models
.CharField(max_length
=255)
179 nom_long
= models
.CharField(max_length
=255, blank
=True)
180 nom_court
= models
.CharField(max_length
=255, blank
=True)
182 actif
= models
.BooleanField()
185 db_table
= u
'ref_discipline'
189 def __unicode__(self
):
190 return "%s - %s" % (self
.code
, self
.nom
)
192 class Programme(models
.Model
):
193 """ ATTENTION: DÉSUET
194 Programme (donnée de référence, source: SQI).
195 Structure interne par laquelle l'AUF exécute ses projets et activités, dispense ses produits et ses services.
198 id = models
.IntegerField(primary_key
=True)
199 code
= models
.CharField(max_length
=255, unique
=True)
200 nom
= models
.CharField(max_length
=255)
201 nom_long
= models
.CharField(max_length
=255, blank
=True)
202 nom_court
= models
.CharField(max_length
=255, blank
=True)
204 actif
= models
.BooleanField()
207 db_table
= u
'ref_programme'
210 def __unicode__(self
):
211 return "%s - %s" % (self
.code
, self
.nom
)
213 #PROGRAMMATION QUADRIENNALLE
216 ('1', "Direction de la langue et de la communication scientifique en français"),
217 ('2', "Direction du développement et de la valorisation"),
218 ('3', "Direction de l'innovation pédagogique et de l'économie de la connaissance"),
219 ('4', "Direction du renforcement des capacités scientifiques"),
222 class Projet(models
.Model
):
223 """Projet (donnée de référence, source: programmation-quadriennalle).
226 id = models
.IntegerField(primary_key
=True)
227 code
= models
.CharField(max_length
=255, unique
=True)
228 nom
= models
.CharField(max_length
=255)
229 presentation
= models
.TextField(null
=True, blank
=True)
230 partenaires
= models
.TextField(null
=True, blank
=True)
231 service
= models
.CharField(max_length
=255, choices
=SERVICE_CHOICES
, blank
=True, null
=True)
232 objectif_specifique
= models
.ForeignKey('ObjectifSpecifique', blank
=True, null
=True, db_column
='objectif_specifique')
233 implantation
= models
.ForeignKey('Implantation', null
=True, blank
=True, db_column
='implantation')
234 etablissement
= models
.ForeignKey('Etablissement', null
=True, blank
=True, db_column
='etablissement')
235 date_debut
= models
.DateField(null
=True, blank
=True)
236 date_fin
= models
.DateField(null
=True, blank
=True)
238 actif
= models
.BooleanField()
241 db_table
= u
'ref_projet'
245 def __unicode__(self
):
246 return "%s - %s" % (self
.code
, self
.nom
)
248 class ProjetComposante(models
.Model
):
249 """Composantes des projets (source: programmation-quadriennalle)
251 id = models
.IntegerField(primary_key
=True)
252 code
= models
.CharField(max_length
=10)
253 nom
= models
.CharField(max_length
=255)
254 nom_court
= models
.CharField(max_length
=255, null
=True, blank
=True)
255 description
= models
.TextField(null
=True, blank
=True)
256 projet
= models
.ForeignKey('Projet', db_column
='projet')
258 actif
= models
.BooleanField()
261 db_table
= u
'ref_projet_composante'
265 def __unicode__(self
):
266 return "%s - %s" % (self
.code
, self
.nom
)
268 class UniteProjet(models
.Model
):
269 """Unités de projet (source: programmation-quadriennalle)
271 id = models
.IntegerField(primary_key
=True)
272 code
= models
.CharField(max_length
=10, unique
=True)
273 nom
= models
.CharField(max_length
=255)
275 actif
= models
.BooleanField()
278 db_table
= u
'ref_unite_projet'
282 def __unicode__(self
):
283 return "%s - %s" % (self
.code
, self
.nom
)
285 class ObjectifSpecifique(models
.Model
):
286 id = models
.IntegerField(primary_key
=True)
287 nom
= models
.CharField(max_length
=255)
288 objectif_strategique
= models
.ForeignKey('ObjectifStrategique', db_column
='objectif_strategique')
290 actif
= models
.BooleanField()
293 db_table
= u
'ref_objectif_specifique'
297 def __unicode__(self
):
298 return "%s - %s" % (self
.id, self
.nom
)
300 class ObjectifStrategique(models
.Model
):
301 id = models
.IntegerField(primary_key
=True)
302 nom
= models
.CharField(max_length
=255)
303 description
= models
.TextField(null
=True, blank
=True)
305 actif
= models
.BooleanField()
308 db_table
= u
'ref_objectif_strategique'
312 def __unicode__(self
):
313 return "%s - %s" % (self
.id, self
.nom
)
315 class Thematique(models
.Model
):
316 id = models
.IntegerField(primary_key
=True)
317 nom
= models
.CharField(max_length
=255)
319 actif
= models
.BooleanField()
322 db_table
= u
'ref_thematique'
326 def __unicode__(self
):
327 return "%s - %s" % (self
.id, self
.nom
)
329 class ProjetUp(models
.Model
):
330 """Projet-unité de projet (source: coda)
333 id = models
.AutoField(primary_key
=True)
334 code
= models
.CharField(max_length
=255, unique
=True)
335 nom
= models
.CharField(max_length
=255)
336 nom_court
= models
.CharField(max_length
=255, blank
=True)
338 actif
= models
.BooleanField()
343 class Poste(models
.Model
):
344 """ ATTENTION: DÉSUET
345 Poste (donnée de référence, source: CODA).
346 Un poste est une catégorie destinée à venir raffiner un projet.
349 id = models
.IntegerField(primary_key
=True)
350 code
= models
.CharField(max_length
=255, unique
=True)
351 nom
= models
.CharField(max_length
=255)
352 type = models
.CharField(max_length
=255, blank
=True)
354 actif
= models
.BooleanField()
357 db_table
= u
'ref_poste'
360 def __unicode__(self
):
361 return "%s - %s (%s)" % (self
.code
, self
.nom
, self
.type)
363 class ProjetPoste(models
.Model
):
364 """ ATTENTION: DÉSUET
365 Projet-poste (donnée de référence, source: CODA).
366 Un projet-poste consiste en une raffinement d'un projet par un poste (budgétaire).
367 Subdivision utile pour le suivi budgétaire et comptable.
370 id = models
.IntegerField(primary_key
=True)
371 code
= models
.CharField(max_length
=255, unique
=True)
372 code_projet
= models
.ForeignKey('Projet', to_field
='code', db_column
='code_projet')
373 code_poste
= models
.ForeignKey('Poste', to_field
='code', db_column
='code_poste')
374 code_bureau
= models
.ForeignKey('Bureau', to_field
='code', db_column
='code_bureau')
375 code_programme
= models
.ForeignKey('Programme', to_field
='code', db_column
='code_programme')
377 actif
= models
.BooleanField()
380 db_table
= u
'ref_projet_poste'
383 def __unicode__(self
):
384 return "%s" % (self
.code
)
388 class Pays(managedref
.Pays
):
395 class Region(managedref
.Region
):
402 class Bureau(managedref
.Bureau
):
409 class Implantation(managedref
.Implantation
):
416 class Etablissement(managedref
.Etablissement
):
423 ### Modèles abstraits
425 class EtablissementBase(managedref
.EtablissementBase
):
426 ref
= models
.ForeignKey(Etablissement
, blank
=True, null
=True)
431 def save(self
, *args
, **kwargs
):
432 if self
.ref
and not self
.pk
:
433 # Nouvel établissement faisant référence à un établissement dans
434 # les références. On copie tous les champs.
435 for f
in self
.ref
._meta
.fields
:
436 if f
.attname
!= 'id':
437 setattr(self
, f
.attname
, getattr(self
.ref
, f
.attname
))
438 super(EtablissementBase
, self
).save(*args
, **kwargs
)