1 # -=- encoding: utf-8 -=-
3 from django
.db
import models
5 class Employe(models
.Model
):
6 """Personne en contrat d'employé (CDD ou CDI) à l'AUF
8 id = models
.IntegerField(primary_key
=True)
9 nom
= models
.CharField(max_length
=255)
10 prenom
= models
.CharField(max_length
=255)
11 implantation
= models
.ForeignKey(to
='Implantation', db_column
='implantation', related_name
='lieu_travail_theorique_de') # SGRH
12 implantation_physique
= models
.ForeignKey(to
='Implantation', db_column
='implantation_physique', related_name
='lieu_travail_reel_de')
13 courriel
= models
.CharField(max_length
=255, null
=True, blank
=True)
14 genre
= models
.CharField(max_length
=3)
15 fonction
= models
.CharField(max_length
=255, null
=True, blank
=True)
16 telephone_poste
= models
.CharField(max_length
=255, null
=True, blank
=True)
17 telephone_ip
= models
.CharField(max_length
=255, null
=True, blank
=True)
18 responsable
= models
.ForeignKey(to
='Employe', db_column
='responsable', related_name
='responsable_de', null
=True, blank
=True)
19 mandat_debut
= models
.DateField(null
=True, blank
=True)
20 mandat_fin
= models
.DateField(null
=True, blank
=True)
21 date_entree
= models
.DateField(null
=True, blank
=True)
22 service
= models
.ForeignKey('Service', db_column
='service')
23 poste_type_1
= models
.ForeignKey('PosteType', null
=True, blank
=True, db_column
='poste_type_1', related_name
='poste_type_1')
24 poste_type_2
= models
.ForeignKey('PosteType', null
=True, blank
=True, db_column
='poste_type_2', related_name
='poste_type_2')
26 actif
= models
.BooleanField()
29 db_table
= u
'ref_employe'
33 def __unicode__(self
):
34 return u
"%s, %s [%d]" % (self
.nom
, self
.prenom
, self
.id)
36 class Authentification(models
.Model
):
37 """Authentification"""
38 id = models
.ForeignKey('Employe', primary_key
=True, db_column
='id')
39 courriel
= models
.CharField(max_length
=255, unique
=True)
40 motdepasse
= models
.CharField(max_length
=255)
41 actif
= models
.BooleanField()
44 db_table
= u
'ref_authentification'
48 def __unicode__(self
):
49 return u
"%s [%d]" % (self
.courriel
, self
.id)
51 class Service(models
.Model
):
52 """Services (donnée de référence, source: SGRH).
54 id = models
.IntegerField(primary_key
=True)
55 nom
= models
.CharField(max_length
=255)
56 actif
= models
.BooleanField()
59 db_table
= u
'ref_service'
63 def __unicode__(self
):
64 return "%s (%s)" % (self
.nom
, self
.id)
66 class PosteType(models
.Model
):
67 """Postes types (donnée de référence, source: SGRH).
69 id = models
.IntegerField(primary_key
=True)
70 nom
= models
.CharField(max_length
=255)
71 actif
= models
.BooleanField()
74 db_table
= u
'ref_poste_type'
77 def __unicode__(self
):
78 return "%s (%s)" % (self
.nom
, self
.id)
80 class GroupeArh(models
.Model
):
81 id = models
.AutoField(primary_key
=True)
82 employe
= models
.ForeignKey('Employe', db_column
='employe')
83 actif
= models
.BooleanField()
86 db_table
= u
'ref_groupe_arh'
89 class GroupeDirRegion(models
.Model
):
90 id = models
.AutoField(primary_key
=True)
91 employe
= models
.ForeignKey('Employe', db_column
='employe')
92 region
= models
.ForeignKey('Region', db_column
='region')
93 actif
= models
.BooleanField()
96 db_table
= u
'ref_groupe_dir_region'
99 class GroupeAdmRegion(models
.Model
):
100 id = models
.AutoField(primary_key
=True)
101 employe
= models
.ForeignKey('Employe', db_column
='employe')
102 region
= models
.ForeignKey('Region', db_column
='region')
103 actif
= models
.BooleanField()
106 db_table
= u
'ref_groupe_adm_region'
109 class GroupeRespImplantation(models
.Model
):
110 id = models
.AutoField(primary_key
=True)
111 employe
= models
.ForeignKey('Employe', db_column
='employe')
112 implantation
= models
.ForeignKey('Implantation', db_column
='implantation')
113 type = models
.CharField(max_length
=255, blank
=True, null
=True)
114 actif
= models
.BooleanField()
117 db_table
= u
'ref_groupe_resp_implantation'
120 class GroupeDirProgramme(models
.Model
):
121 id = models
.AutoField(primary_key
=True)
122 employe
= models
.ForeignKey('Employe', db_column
='employe')
123 service
= models
.ForeignKey('Service', db_column
='service')
124 actif
= models
.BooleanField()
127 db_table
= u
'ref_groupe_dir_programme'
130 class GroupeDirDelegProgrammeReg(models
.Model
):
131 id = models
.AutoField(primary_key
=True)
132 employe
= models
.ForeignKey('Employe', db_column
='employe')
133 region
= models
.ForeignKey('Region', db_column
='region')
134 actif
= models
.BooleanField()
137 db_table
= u
'ref_groupe_dir_deleg_programme_reg'
140 class GroupeComptable(models
.Model
):
141 id = models
.AutoField(primary_key
=True)
142 employe
= models
.ForeignKey('Employe', db_column
='employe')
143 actif
= models
.BooleanField()
146 db_table
= u
'ref_groupe_comptable'
149 class GroupeComptableRegional(models
.Model
):
150 id = models
.AutoField(primary_key
=True)
151 employe
= models
.ForeignKey('Employe', db_column
='employe')
152 actif
= models
.BooleanField()
155 db_table
= u
'ref_groupe_comptable_regional'
158 class GroupeComptableLocal(models
.Model
):
159 id = models
.AutoField(primary_key
=True)
160 employe
= models
.ForeignKey('Employe', db_column
='employe')
161 actif
= models
.BooleanField()
164 db_table
= u
'ref_groupe_comptable_local'
167 class Pays(models
.Model
):
168 """Pays (donnée de référence, source: SQI).
169 Liste AUF basée sur la liste ISO-3166-1.
172 id = models
.IntegerField(primary_key
=True)
173 code
= models
.CharField(max_length
=2, unique
=True)
174 code_iso3
= models
.CharField(max_length
=3, unique
=True, blank
=True)
175 nom
= models
.CharField(max_length
=255)
176 region
= models
.ForeignKey('Region', db_column
='region')
177 code_bureau
= models
.ForeignKey('Bureau', to_field
='code', db_column
='code_bureau')
178 nord_sud
= models
.CharField(max_length
=255, blank
=True, null
=True)
179 developpement
= models
.CharField(max_length
=255, blank
=True, null
=True)
180 monnaie
= models
.CharField(max_length
=255, blank
=True, null
=True)
182 actif
= models
.BooleanField()
185 db_table
= u
'ref_pays'
187 verbose_name
= u
"pays"
188 verbose_name_plural
= u
"pays"
191 def __unicode__(self
):
192 return "%s (%s)" % (self
.nom
, self
.code
)
194 class Region(models
.Model
):
195 """Région (donnée de référence, source: referentiels_spip).
196 Une région est une subdivision géographique du monde pour la gestion de l'AUF.
199 id = models
.IntegerField(primary_key
=True)
200 code
= models
.CharField(max_length
=255, unique
=True)
201 nom
= models
.CharField(max_length
=255)
202 implantation_bureau
= models
.ForeignKey('Implantation', db_column
='implantation_bureau', related_name
='gere_region')
204 actif
= models
.BooleanField()
207 db_table
= u
'ref_region'
209 verbose_name
= u
"région"
210 verbose_name_plural
= u
"régions"
213 def __unicode__(self
):
214 return "%s (%s)" % (self
.nom
, self
.code
)
216 class Bureau(models
.Model
):
217 """Bureau (donnée de référence, source: SQI).
218 Référence legacy entre la notion de région et celle d'implantation responsable des régions et du central.
220 - soit le bureau régional d'une région (implantations de type 'Bureau')
221 - soit la notion unique de Service central pour les 2 implantations centrales (implantations de type 'Service central' et 'Siege').
222 Ne pas confondre avec les seuls 'bureaux régionaux'.
225 id = models
.IntegerField(primary_key
=True)
226 code
= models
.CharField(max_length
=255, unique
=True)
227 nom
= models
.CharField(max_length
=255)
228 nom_court
= models
.CharField(max_length
=255, blank
=True)
229 nom_long
= models
.CharField(max_length
=255, blank
=True)
230 implantation
= models
.ForeignKey('Implantation', db_column
='implantation')
231 region
= models
.ForeignKey('Region', db_column
='region')
233 actif
= models
.BooleanField()
236 db_table
= u
'ref_bureau'
238 verbose_name
= u
"bureau"
239 verbose_name_plural
= u
"bureaux"
242 def __unicode__(self
):
243 return "%s (%s)" % (self
.nom
, self
.code
)
245 class Discipline(models
.Model
):
246 """ ATTENTION: DÉSUET
247 Discipline (donnée de référence, source: SQI).
248 Une discipline est une catégorie de savoirs scientifiques.
249 Le conseil scientifique fixe la liste des disciplines.
252 id = models
.IntegerField(primary_key
=True)
253 code
= models
.CharField(max_length
=255, unique
=True)
254 nom
= models
.CharField(max_length
=255)
255 nom_long
= models
.CharField(max_length
=255, blank
=True)
256 nom_court
= models
.CharField(max_length
=255, blank
=True)
258 actif
= models
.BooleanField()
261 db_table
= u
'ref_discipline'
265 def __unicode__(self
):
266 return "%s - %s" % (self
.code
, self
.nom
)
268 class EtablissementManager(models
.Manager
):
270 def get_query_set(self
):
271 qs
= super(EtablissementManager
, self
).get_query_set()
272 return qs
.select_related('pays')
274 class Etablissement(models
.Model
):
275 """Établissement (donnée de référence, source: GDE).
276 Un établissement peut être une université, un centre de recherche, un réseau d'établissement...
277 Un établissement peut être membre de l'AUF ou non.
280 id = models
.IntegerField(primary_key
=True)
281 nom
= models
.CharField(max_length
=255)
282 pays
= models
.ForeignKey('Pays', to_field
='code', db_column
='pays')
283 region
= models
.ForeignKey('Region', db_column
='region')
284 implantation
= models
.ForeignKey('Implantation', db_column
='implantation', related_name
='gere_etablissement')
285 code_implantation
= models
.ForeignKey('Implantation', to_field
='code', db_column
='code_implantation', related_name
='code_gere_etablissement')
287 membre
= models
.BooleanField()
288 membre_adhesion_date
= models
.DateField(null
=True, blank
=True)
290 responsable_genre
= models
.CharField(max_length
=1, blank
=True)
291 responsable_nom
= models
.CharField(max_length
=255, blank
=True)
292 responsable_prenom
= models
.CharField(max_length
=255, blank
=True)
294 adresse
= models
.CharField(max_length
=255, blank
=True)
295 code_postal
= models
.CharField(max_length
=20, blank
=True)
296 cedex
= models
.CharField(max_length
=20, blank
=True)
297 ville
= models
.CharField(max_length
=255, blank
=True)
298 province
= models
.CharField(max_length
=255, blank
=True)
299 telephone
= models
.CharField(max_length
=255, blank
=True)
300 fax
= models
.CharField(max_length
=255, blank
=True)
301 url
= models
.URLField(verify_exists
=False, max_length
=255, null
=True, blank
=True)
303 actif
= models
.BooleanField()
305 objects
= EtablissementManager()
308 db_table
= u
'ref_etablissement'
309 ordering
= ['pays__nom', 'nom']
312 def __unicode__(self
):
313 return "%s - %s (%d)" % (self
.pays
.nom
, self
.nom
, self
.id)
315 class Implantation(models
.Model
):
316 """Implantation (donnée de référence, source: Implantus)
317 Une implantation est un endroit où l'AUF est présente et offre des services spécifiques.
318 Deux implantations peuvent être au même endroit physique.
321 id = models
.IntegerField(primary_key
=True)
322 code
= models
.CharField(max_length
=255, unique
=True)
323 nom
= models
.CharField(max_length
=255)
324 nom_court
= models
.CharField(max_length
=255, blank
=True)
325 nom_long
= models
.CharField(max_length
=255, blank
=True)
326 type = models
.CharField(max_length
=255)
327 bureau_rattachement
= models
.ForeignKey('Implantation', db_column
='bureau_rattachement')
328 region
= models
.ForeignKey('Region', db_column
='region')
329 fuseau_horaire
= models
.CharField(max_length
=255, blank
=True)
330 code_meteo
= models
.CharField(max_length
=255, blank
=True)
332 responsable_implantation
= models
.IntegerField(null
=True, blank
=True) # models.ForeignKey('Employe')
334 adresse_postale_precision_avant
= models
.CharField(max_length
=255, blank
=True, null
=True)
335 adresse_postale_no
= models
.CharField(max_length
=30, blank
=True, null
=True)
336 adresse_postale_rue
= models
.CharField(max_length
=255, blank
=True, null
=True)
337 adresse_postale_bureau
= models
.CharField(max_length
=255, blank
=True, null
=True)
338 adresse_postale_precision
= models
.CharField(max_length
=255, blank
=True, null
=True)
339 adresse_postale_boite_postale
= models
.CharField(max_length
=255, blank
=True, null
=True)
340 adresse_postale_ville
= models
.CharField(max_length
=255)
341 adresse_postale_code_postal
= models
.CharField(max_length
=20, blank
=True, null
=True)
342 adresse_postale_code_postal_avant_ville
= models
.NullBooleanField()
343 adresse_postale_region
= models
.CharField(max_length
=255, blank
=True, null
=True)
344 adresse_postale_pays
= models
.ForeignKey('Pays', to_field
='code', db_column
='adresse_postale_pays', related_name
='impl_adresse_postale')
346 adresse_physique_precision_avant
= models
.CharField(max_length
=255, blank
=True)
347 adresse_physique_no
= models
.CharField(max_length
=30, blank
=True)
348 adresse_physique_rue
= models
.CharField(max_length
=255, blank
=True)
349 adresse_physique_bureau
= models
.CharField(max_length
=255, blank
=True)
350 adresse_physique_precision
= models
.CharField(max_length
=255, blank
=True)
351 adresse_physique_ville
= models
.CharField(max_length
=255)
352 adresse_physique_code_postal
= models
.CharField(max_length
=30, blank
=True)
353 adresse_physique_code_postal_avant_ville
= models
.NullBooleanField()
354 adresse_physique_region
= models
.CharField(max_length
=255, blank
=True)
355 adresse_physique_pays
= models
.ForeignKey('Pays', to_field
='code', db_column
='adresse_physique_pays', related_name
='impl_adresse_physique')
357 telephone
= models
.CharField(max_length
=255, blank
=True)
358 telephone_interne
= models
.CharField(max_length
=255, blank
=True)
359 fax
= models
.CharField(max_length
=255, blank
=True)
360 fax_interne
= models
.CharField(max_length
=255, blank
=True)
361 courriel
= models
.EmailField(blank
=True)
362 courriel_interne
= models
.EmailField(blank
=True)
363 url
= models
.URLField(verify_exists
=False, max_length
=255, blank
=True)
365 statut
= models
.IntegerField()
366 date_ouverture
= models
.DateField(null
=True, blank
=True)
367 date_inauguration
= models
.DateField(null
=True, blank
=True)
368 date_extension
= models
.DateField(null
=True, blank
=True)
369 date_fermeture
= models
.DateField(null
=True, blank
=True)
370 hebergement_etablissement
= models
.CharField(max_length
=255, blank
=True) # models.ForeignKey('Etablissement', db_column='hebergement_etablissement')
371 hebergement_convention
= models
.NullBooleanField()
372 hebergement_convention_date
= models
.DateField(null
=True, blank
=True)
373 remarque
= models
.TextField()
374 commentaire
= models
.CharField(max_length
=255, blank
=True)
376 actif
= models
.BooleanField()
377 modif_date
= models
.DateField()
381 class Ouvertes(models
.Manager
):
383 def get_query_set(self
):
384 return super(Implantation
.Managers
.Ouvertes
, self
).get_query_set().filter(
388 class Actifs(models
.Manager
):
390 def get_query_set(self
):
391 return super(Implantation
.Managers
.Actifs
, self
).get_query_set().filter(actif
=True)
393 objects
= models
.Manager()
394 ouvertes
= Managers
.Ouvertes()
395 actifs
= Managers
.Actifs()
399 db_table
= u
'ref_implantation'
403 def __unicode__(self
):
404 return "%s (%d)" % (self
.nom
, self
.id)
406 class Programme(models
.Model
):
407 """ ATTENTION: DÉSUET
408 Programme (donnée de référence, source: SQI).
409 Structure interne par laquelle l'AUF exécute ses projets et activités, dispense ses produits et ses services.
412 id = models
.IntegerField(primary_key
=True)
413 code
= models
.CharField(max_length
=255, unique
=True)
414 nom
= models
.CharField(max_length
=255)
415 nom_long
= models
.CharField(max_length
=255, blank
=True)
416 nom_court
= models
.CharField(max_length
=255, blank
=True)
418 actif
= models
.BooleanField()
421 db_table
= u
'ref_programme'
424 def __unicode__(self
):
425 return "%s - %s" % (self
.code
, self
.nom
)
427 #PROGRAMMATION QUADRIENNALLE
430 ('1', "Direction de la langue et de la communication scientifique en français"),
431 ('2', "Direction du développement et de la valorisation"),
432 ('3', "Direction de l'innovation pédagogique et de l'économie de la connaissance"),
433 ('4', "Direction du renforcement des capacités scientifiques"),
436 class Projet(models
.Model
):
437 """Projet (donnée de référence, source: programmation-quadriennalle).
440 id = models
.IntegerField(primary_key
=True)
441 code
= models
.CharField(max_length
=255, unique
=True)
442 nom
= models
.CharField(max_length
=255)
443 presentation
= models
.TextField(null
=True, blank
=True)
444 partenaires
= models
.TextField(null
=True, blank
=True)
445 service
= models
.CharField(max_length
=255, choices
=SERVICE_CHOICES
, blank
=True, null
=True)
446 objectif_specifique
= models
.ForeignKey('ObjectifSpecifique', blank
=True, null
=True, db_column
='objectif_specifique')
447 implantation
= models
.ForeignKey('Implantation', null
=True, blank
=True, db_column
='implantation')
448 etablissement
= models
.ForeignKey('Etablissement', null
=True, blank
=True, db_column
='etablissement')
449 date_debut
= models
.DateField(null
=True, blank
=True)
450 date_fin
= models
.DateField(null
=True, blank
=True)
452 actif
= models
.BooleanField()
455 db_table
= u
'ref_projet'
459 def __unicode__(self
):
460 return "%s - %s" % (self
.code
, self
.nom
)
462 class ProjetComposante(models
.Model
):
463 """Composantes des projets (source: programmation-quadriennalle)
465 id = models
.IntegerField(primary_key
=True)
466 code
= models
.CharField(max_length
=10)
467 nom
= models
.CharField(max_length
=255)
468 nom_court
= models
.CharField(max_length
=255, null
=True, blank
=True)
469 description
= models
.TextField(null
=True, blank
=True)
470 projet
= models
.ForeignKey('Projet', db_column
='projet')
472 actif
= models
.BooleanField()
475 db_table
= u
'ref_projet_composante'
479 def __unicode__(self
):
480 return "%s - %s" % (self
.code
, self
.nom
)
482 class UniteProjet(models
.Model
):
483 """Unités de projet (source: programmation-quadriennalle)
485 id = models
.IntegerField(primary_key
=True)
486 code
= models
.CharField(max_length
=10, unique
=True)
487 nom
= models
.CharField(max_length
=255)
489 actif
= models
.BooleanField()
492 db_table
= u
'ref_unite_projet'
496 def __unicode__(self
):
497 return "%s - %s" % (self
.code
, self
.nom
)
499 class ObjectifSpecifique(models
.Model
):
500 id = models
.IntegerField(primary_key
=True)
501 nom
= models
.CharField(max_length
=255)
502 objectif_strategique
= models
.ForeignKey('ObjectifStrategique', db_column
='objectif_strategique')
504 actif
= models
.BooleanField()
507 db_table
= u
'ref_objectif_specifique'
511 def __unicode__(self
):
512 return "%s - %s" % (self
.id, self
.nom
)
514 class ObjectifStrategique(models
.Model
):
515 id = models
.IntegerField(primary_key
=True)
516 nom
= models
.CharField(max_length
=255)
517 description
= models
.TextField(null
=True, blank
=True)
519 actif
= models
.BooleanField()
522 db_table
= u
'ref_objectif_strategique'
526 def __unicode__(self
):
527 return "%s - %s" % (self
.id, self
.nom
)
529 class Thematique(models
.Model
):
530 id = models
.IntegerField(primary_key
=True)
531 nom
= models
.CharField(max_length
=255)
533 actif
= models
.BooleanField()
536 db_table
= u
'ref_thematique'
540 def __unicode__(self
):
541 return "%s - %s" % (self
.id, self
.nom
)
543 class ProjetUp(models
.Model
):
544 """Projet-unité de projet (source: coda)
547 id = models
.AutoField(primary_key
=True)
548 code
= models
.CharField(max_length
=255, unique
=True)
549 nom
= models
.CharField(max_length
=255)
550 nom_court
= models
.CharField(max_length
=255, blank
=True)
552 actif
= models
.BooleanField()
557 class Poste(models
.Model
):
558 """ ATTENTION: DÉSUET
559 Poste (donnée de référence, source: CODA).
560 Un poste est une catégorie destinée à venir raffiner un projet.
563 id = models
.IntegerField(primary_key
=True)
564 code
= models
.CharField(max_length
=255, unique
=True)
565 nom
= models
.CharField(max_length
=255)
566 type = models
.CharField(max_length
=255, blank
=True)
568 actif
= models
.BooleanField()
571 db_table
= u
'ref_poste'
574 def __unicode__(self
):
575 return "%s - %s (%s)" % (self
.code
, self
.nom
, self
.type)
577 class ProjetPoste(models
.Model
):
578 """ ATTENTION: DÉSUET
579 Projet-poste (donnée de référence, source: CODA).
580 Un projet-poste consiste en une raffinement d'un projet par un poste (budgétaire).
581 Subdivision utile pour le suivi budgétaire et comptable.
584 id = models
.IntegerField(primary_key
=True)
585 code
= models
.CharField(max_length
=255, unique
=True)
586 code_projet
= models
.ForeignKey('Projet', to_field
='code', db_column
='code_projet')
587 code_poste
= models
.ForeignKey('Poste', to_field
='code', db_column
='code_poste')
588 code_bureau
= models
.ForeignKey('Bureau', to_field
='code', db_column
='code_bureau')
589 code_programme
= models
.ForeignKey('Programme', to_field
='code', db_column
='code_programme')
591 actif
= models
.BooleanField()
594 db_table
= u
'ref_projet_poste'
597 def __unicode__(self
):
598 return "%s" % (self
.code
)