3 from django
.db
import models
6 class Employe(models
.Model
):
7 """Personne en contrat d'employé (CDD ou CDI) à l'AUF
9 id = models
.IntegerField(primary_key
=True)
10 nom
= models
.CharField(max_length
=255)
11 prenom
= models
.CharField(max_length
=255)
12 implantation
= models
.ForeignKey(to
='Implantation', db_column
='implantation', related_name
='lieu_travail_theorique_de') # SGRH
13 implantation_physique
= models
.ForeignKey(to
='Implantation', db_column
='implantation_physique', related_name
='lieu_travail_reel_de')
14 courriel
= models
.CharField(max_length
=255, null
=True, blank
=True)
15 genre
= models
.CharField(max_length
=3)
16 fonction
= models
.CharField(max_length
=255, null
=True, blank
=True)
17 telephone_poste
= models
.CharField(max_length
=255, null
=True, blank
=True)
18 telephone_ip
= models
.CharField(max_length
=255, null
=True, blank
=True)
19 responsable
= models
.ForeignKey(to
='Employe', db_column
='responsable', related_name
='responsable_de', null
=True, blank
=True)
20 mandat_debut
= models
.DateField(null
=True, blank
=True)
21 mandat_fin
= models
.DateField(null
=True, blank
=True)
22 date_entree
= models
.DateField(null
=True, blank
=True)
23 service
= models
.ForeignKey('Service', db_column
='service')
24 poste_type_1
= models
.ForeignKey('PosteType', null
=True, blank
=True, db_column
='poste_type_1', related_name
='poste_type_1')
25 poste_type_2
= models
.ForeignKey('PosteType', null
=True, blank
=True, db_column
='poste_type_2', related_name
='poste_type_2')
27 actif
= models
.BooleanField()
30 db_table
= u
'ref_employe'
33 def __unicode__(self
):
34 return u
"%s, %s [%d]" % (self
.nom
, self
.prenom
, self
.id)
37 class Authentification(models
.Model
):
38 """Authentification"""
39 id = models
.ForeignKey('Employe', primary_key
=True, db_column
='id')
40 courriel
= models
.CharField(max_length
=255, unique
=True)
41 motdepasse
= models
.CharField(max_length
=255)
42 actif
= models
.BooleanField()
45 db_table
= u
'ref_authentification'
48 def __unicode__(self
):
49 return u
"%s [%d]" % (self
.courriel
, self
.id)
52 class Service(models
.Model
):
53 """Services (donnée de référence, source: SGRH).
55 id = models
.IntegerField(primary_key
=True)
56 nom
= models
.CharField(max_length
=255)
57 actif
= models
.BooleanField()
60 db_table
= u
'ref_service'
63 def __unicode__(self
):
64 return "%s (%s)" % (self
.nom
, self
.id)
67 class PosteType(models
.Model
):
68 """Postes types (donnée de référence, source: SGRH).
70 id = models
.IntegerField(primary_key
=True)
71 nom
= models
.CharField(max_length
=255)
72 actif
= models
.BooleanField()
75 db_table
= u
'ref_poste_type'
77 def __unicode__(self
):
78 return "%s (%s)" % (self
.nom
, self
.id)
81 class GroupeArh(models
.Model
):
82 id = models
.AutoField(primary_key
=True)
83 employe
= models
.ForeignKey('Employe', db_column
='employe')
84 actif
= models
.BooleanField()
87 db_table
= u
'ref_groupe_arh'
90 class GroupeDirRegion(models
.Model
):
91 id = models
.AutoField(primary_key
=True)
92 employe
= models
.ForeignKey('Employe', db_column
='employe')
93 region
= models
.ForeignKey('Region', db_column
='region')
94 actif
= models
.BooleanField()
97 db_table
= u
'ref_groupe_dir_region'
100 class GroupeAdmRegion(models
.Model
):
101 id = models
.AutoField(primary_key
=True)
102 employe
= models
.ForeignKey('Employe', db_column
='employe')
103 region
= models
.ForeignKey('Region', db_column
='region')
104 actif
= models
.BooleanField()
107 db_table
= u
'ref_groupe_adm_region'
110 class GroupeRespImplantation(models
.Model
):
111 id = models
.AutoField(primary_key
=True)
112 employe
= models
.ForeignKey('Employe', db_column
='employe')
113 implantation
= models
.ForeignKey('Implantation', db_column
='implantation')
114 type = models
.CharField(max_length
=255, blank
=True, null
=True)
115 actif
= models
.BooleanField()
118 db_table
= u
'ref_groupe_resp_implantation'
121 class GroupeDirProgramme(models
.Model
):
122 id = models
.AutoField(primary_key
=True)
123 employe
= models
.ForeignKey('Employe', db_column
='employe')
124 service
= models
.ForeignKey('Service', db_column
='service')
125 actif
= models
.BooleanField()
128 db_table
= u
'ref_groupe_dir_programme'
131 class GroupeDirDelegProgrammeReg(models
.Model
):
132 id = models
.AutoField(primary_key
=True)
133 employe
= models
.ForeignKey('Employe', db_column
='employe')
134 region
= models
.ForeignKey('Region', db_column
='region')
135 actif
= models
.BooleanField()
138 db_table
= u
'ref_groupe_dir_deleg_programme_reg'
141 class GroupeComptable(models
.Model
):
142 id = models
.AutoField(primary_key
=True)
143 employe
= models
.ForeignKey('Employe', db_column
='employe')
144 actif
= models
.BooleanField()
147 db_table
= u
'ref_groupe_comptable'
150 class GroupeComptableRegional(models
.Model
):
151 id = models
.AutoField(primary_key
=True)
152 employe
= models
.ForeignKey('Employe', db_column
='employe')
153 actif
= models
.BooleanField()
156 db_table
= u
'ref_groupe_comptable_regional'
159 class GroupeComptableLocal(models
.Model
):
160 id = models
.AutoField(primary_key
=True)
161 employe
= models
.ForeignKey('Employe', db_column
='employe')
162 actif
= models
.BooleanField()
165 db_table
= u
'ref_groupe_comptable_local'
168 class Discipline(models
.Model
):
169 """ ATTENTION: DÉSUET
170 Discipline (donnée de référence, source: SQI).
171 Une discipline est une catégorie de savoirs scientifiques.
172 Le conseil scientifique fixe la liste des disciplines.
175 id = models
.IntegerField(primary_key
=True)
176 code
= models
.CharField(max_length
=255, unique
=True)
177 nom
= models
.CharField(max_length
=255)
178 nom_long
= models
.CharField(max_length
=255, blank
=True)
179 nom_court
= models
.CharField(max_length
=255, blank
=True)
181 actif
= models
.BooleanField()
184 db_table
= u
'ref_discipline'
187 def __unicode__(self
):
188 return "%s - %s" % (self
.code
, self
.nom
)
191 class Programme(models
.Model
):
192 """ ATTENTION: DÉSUET
193 Programme (donnée de référence, source: SQI).
194 Structure interne par laquelle l'AUF exécute ses projets et activités, dispense ses produits et ses services.
197 id = models
.IntegerField(primary_key
=True)
198 code
= models
.CharField(max_length
=255, unique
=True)
199 nom
= models
.CharField(max_length
=255)
200 nom_long
= models
.CharField(max_length
=255, blank
=True)
201 nom_court
= models
.CharField(max_length
=255, blank
=True)
203 actif
= models
.BooleanField()
206 db_table
= u
'ref_programme'
208 def __unicode__(self
):
209 return "%s - %s" % (self
.code
, self
.nom
)
212 #PROGRAMMATION QUADRIENNALLE
214 class Projet(models
.Model
):
215 """Projet (donnée de référence, source: programmation-quadriennalle).
218 ('1', "Direction de la langue et de la communication scientifique en français"),
219 ('2', "Direction du développement et de la valorisation"),
220 ('3', "Direction de l'innovation pédagogique et de l'économie de la connaissance"),
221 ('4', "Direction du renforcement des capacités scientifiques"),
224 id = models
.IntegerField(primary_key
=True)
225 code
= models
.CharField(max_length
=255, unique
=True)
226 nom
= models
.CharField(max_length
=255)
227 presentation
= models
.TextField(null
=True, blank
=True)
228 partenaires
= models
.TextField(null
=True, blank
=True)
229 service
= models
.CharField(max_length
=255, choices
=SERVICE_CHOICES
, blank
=True, null
=True)
230 objectif_specifique
= models
.ForeignKey('ObjectifSpecifique', blank
=True, null
=True, db_column
='objectif_specifique')
231 implantation
= models
.ForeignKey('Implantation', null
=True, blank
=True, db_column
='implantation')
232 etablissement
= models
.ForeignKey('Etablissement', null
=True, blank
=True, db_column
='etablissement')
233 date_debut
= models
.DateField(null
=True, blank
=True)
234 date_fin
= models
.DateField(null
=True, blank
=True)
236 actif
= models
.BooleanField()
239 db_table
= u
'ref_projet'
242 def __unicode__(self
):
243 return "%s - %s" % (self
.code
, self
.nom
)
246 class ProjetComposante(models
.Model
):
247 """Composantes des projets (source: programmation-quadriennalle)
249 id = models
.IntegerField(primary_key
=True)
250 code
= models
.CharField(max_length
=10)
251 nom
= models
.CharField(max_length
=255)
252 nom_court
= models
.CharField(max_length
=255, null
=True, blank
=True)
253 description
= models
.TextField(null
=True, blank
=True)
254 projet
= models
.ForeignKey('Projet', db_column
='projet')
256 actif
= models
.BooleanField()
259 db_table
= u
'ref_projet_composante'
262 def __unicode__(self
):
263 return "%s - %s" % (self
.code
, self
.nom
)
266 class UniteProjet(models
.Model
):
267 """Unités de projet (source: programmation-quadriennalle)
269 id = models
.IntegerField(primary_key
=True)
270 code
= models
.CharField(max_length
=10, unique
=True)
271 nom
= models
.CharField(max_length
=255)
273 actif
= models
.BooleanField()
276 db_table
= u
'ref_unite_projet'
279 def __unicode__(self
):
280 return "%s - %s" % (self
.code
, self
.nom
)
283 class ObjectifSpecifique(models
.Model
):
284 id = models
.IntegerField(primary_key
=True)
285 nom
= models
.CharField(max_length
=255)
286 objectif_strategique
= models
.ForeignKey('ObjectifStrategique', db_column
='objectif_strategique')
288 actif
= models
.BooleanField()
291 db_table
= u
'ref_objectif_specifique'
294 def __unicode__(self
):
295 return "%s - %s" % (self
.id, self
.nom
)
298 class ObjectifStrategique(models
.Model
):
299 id = models
.IntegerField(primary_key
=True)
300 nom
= models
.CharField(max_length
=255)
301 description
= models
.TextField(null
=True, blank
=True)
303 actif
= models
.BooleanField()
306 db_table
= u
'ref_objectif_strategique'
309 def __unicode__(self
):
310 return "%s - %s" % (self
.id, self
.nom
)
313 class Thematique(models
.Model
):
314 id = models
.IntegerField(primary_key
=True)
315 nom
= models
.CharField(max_length
=255)
317 actif
= models
.BooleanField()
320 db_table
= u
'ref_thematique'
323 def __unicode__(self
):
324 return "%s - %s" % (self
.id, self
.nom
)
327 class ProjetUp(models
.Model
):
328 """Projet-unité de projet (source: coda)
331 id = models
.AutoField(primary_key
=True)
332 code
= models
.CharField(max_length
=255, unique
=True)
333 nom
= models
.CharField(max_length
=255)
334 nom_court
= models
.CharField(max_length
=255, blank
=True)
336 actif
= models
.BooleanField()
339 class Poste(models
.Model
):
340 """ ATTENTION: DÉSUET
341 Poste (donnée de référence, source: CODA).
342 Un poste est une catégorie destinée à venir raffiner un projet.
345 id = models
.IntegerField(primary_key
=True)
346 code
= models
.CharField(max_length
=255, unique
=True)
347 nom
= models
.CharField(max_length
=255)
348 type = models
.CharField(max_length
=255, blank
=True)
350 actif
= models
.BooleanField()
353 db_table
= u
'ref_poste'
355 def __unicode__(self
):
356 return "%s - %s (%s)" % (self
.code
, self
.nom
, self
.type)
359 class ProjetPoste(models
.Model
):
360 """ ATTENTION: DÉSUET
361 Projet-poste (donnée de référence, source: CODA).
362 Un projet-poste consiste en une raffinement d'un projet par un poste (budgétaire).
363 Subdivision utile pour le suivi budgétaire et comptable.
366 id = models
.IntegerField(primary_key
=True)
367 code
= models
.CharField(max_length
=255, unique
=True)
368 code_projet
= models
.ForeignKey('Projet', to_field
='code', db_column
='code_projet')
369 code_poste
= models
.ForeignKey('Poste', to_field
='code', db_column
='code_poste')
370 code_bureau
= models
.ForeignKey('Bureau', to_field
='code', db_column
='code_bureau')
371 code_programme
= models
.ForeignKey('Programme', to_field
='code', db_column
='code_programme')
373 actif
= models
.BooleanField()
376 db_table
= u
'ref_projet_poste'
378 def __unicode__(self
):
379 return "%s" % (self
.code
)
382 class Region(models
.Model
):
383 """Région (donnée de référence, source: referentiels_spip).
384 Une région est une subdivision géographique du monde pour la gestion de l'AUF.
386 code
= models
.CharField(max_length
=255, unique
=True)
387 nom
= models
.CharField(max_length
=255, db_index
=True)
388 implantation_bureau
= models
.ForeignKey('Implantation',
389 db_column
='implantation_bureau',
390 related_name
='gere_region', null
=True, blank
=True)
392 actif
= models
.BooleanField()
395 db_table
= u
'ref_region'
397 verbose_name
= u
"région"
398 verbose_name_plural
= u
"régions"
400 def __unicode__(self
):
401 return "%s (%s)" % (self
.nom
, self
.code
)
404 class Bureau(models
.Model
):
405 """Bureau (donnée de référence, source: SQI).
406 Référence legacy entre la notion de région et celle d'implantation responsable des régions et du central.
408 - soit le bureau régional d'une région (implantations de type 'Bureau')
409 - soit la notion unique de Service central pour les 2 implantations centrales (implantations de type 'Service central' et 'Siege').
410 Ne pas confondre avec les seuls 'bureaux régionaux'.
412 code
= models
.CharField(max_length
=255, unique
=True)
413 nom
= models
.CharField(max_length
=255)
414 nom_court
= models
.CharField(max_length
=255, blank
=True)
415 nom_long
= models
.CharField(max_length
=255, blank
=True)
416 implantation
= models
.ForeignKey('Implantation', db_column
='implantation')
417 region
= models
.ForeignKey('Region', db_column
='region')
419 actif
= models
.BooleanField()
422 db_table
= u
'ref_bureau'
424 verbose_name
= u
"bureau"
425 verbose_name_plural
= u
"bureaux"
427 def __unicode__(self
):
428 return "%s (%s)" % (self
.nom
, self
.code
)
431 class Implantation(models
.Model
):
432 """Implantation (donnée de référence, source: Implantus)
433 Une implantation est un endroit où l'AUF est présente et offre des services spécifiques.
434 Deux implantations peuvent être au même endroit physique.
436 nom
= models
.CharField(max_length
=255)
437 nom_court
= models
.CharField(max_length
=255, blank
=True)
438 nom_long
= models
.CharField(max_length
=255, blank
=True)
439 type = models
.CharField(max_length
=255)
440 bureau_rattachement
= models
.ForeignKey('Implantation', db_column
='bureau_rattachement')
441 region
= models
.ForeignKey('Region', db_column
='region')
442 fuseau_horaire
= models
.CharField(max_length
=255, blank
=True)
443 code_meteo
= models
.CharField(max_length
=255, blank
=True)
445 responsable_implantation
= models
.IntegerField(null
=True, blank
=True) # models.ForeignKey('Employe')
447 adresse_postale_precision_avant
= models
.CharField(max_length
=255, blank
=True, null
=True)
448 adresse_postale_no
= models
.CharField(max_length
=30, blank
=True, null
=True)
449 adresse_postale_rue
= models
.CharField(max_length
=255, blank
=True, null
=True)
450 adresse_postale_bureau
= models
.CharField(max_length
=255, blank
=True, null
=True)
451 adresse_postale_precision
= models
.CharField(max_length
=255, blank
=True, null
=True)
452 adresse_postale_boite_postale
= models
.CharField(max_length
=255, blank
=True, null
=True)
453 adresse_postale_ville
= models
.CharField(max_length
=255)
454 adresse_postale_code_postal
= models
.CharField(max_length
=20, blank
=True, null
=True)
455 adresse_postale_code_postal_avant_ville
= models
.NullBooleanField()
456 adresse_postale_region
= models
.CharField(max_length
=255, blank
=True, null
=True)
457 adresse_postale_pays
= models
.ForeignKey('Pays', to_field
='code', db_column
='adresse_postale_pays', related_name
='impl_adresse_postale')
459 adresse_physique_precision_avant
= models
.CharField(max_length
=255, blank
=True)
460 adresse_physique_no
= models
.CharField(max_length
=30, blank
=True)
461 adresse_physique_rue
= models
.CharField(max_length
=255, blank
=True)
462 adresse_physique_bureau
= models
.CharField(max_length
=255, blank
=True)
463 adresse_physique_precision
= models
.CharField(max_length
=255, blank
=True)
464 adresse_physique_ville
= models
.CharField(max_length
=255)
465 adresse_physique_code_postal
= models
.CharField(max_length
=30, blank
=True)
466 adresse_physique_code_postal_avant_ville
= models
.NullBooleanField()
467 adresse_physique_region
= models
.CharField(max_length
=255, blank
=True)
468 adresse_physique_pays
= models
.ForeignKey('Pays', to_field
='code', db_column
='adresse_physique_pays', related_name
='impl_adresse_physique')
470 telephone
= models
.CharField(max_length
=255, blank
=True)
471 telephone_interne
= models
.CharField(max_length
=255, blank
=True)
472 fax
= models
.CharField(max_length
=255, blank
=True)
473 fax_interne
= models
.CharField(max_length
=255, blank
=True)
474 courriel
= models
.EmailField(blank
=True)
475 courriel_interne
= models
.EmailField(blank
=True)
476 url
= models
.URLField(verify_exists
=False, max_length
=255, blank
=True)
478 statut
= models
.IntegerField()
479 date_ouverture
= models
.DateField(null
=True, blank
=True)
480 date_inauguration
= models
.DateField(null
=True, blank
=True)
481 date_extension
= models
.DateField(null
=True, blank
=True)
482 date_fermeture
= models
.DateField(null
=True, blank
=True)
483 hebergement_etablissement
= models
.CharField(max_length
=255, blank
=True) # models.ForeignKey('Etablissement', db_column='hebergement_etablissement')
484 hebergement_convention
= models
.NullBooleanField()
485 hebergement_convention_date
= models
.DateField(null
=True, blank
=True)
486 remarque
= models
.TextField()
487 commentaire
= models
.CharField(max_length
=255, blank
=True)
489 actif
= models
.BooleanField()
490 modif_date
= models
.DateField()
494 class Ouvertes(models
.Manager
):
496 def get_query_set(self
):
497 return super(Implantation
.Managers
.Ouvertes
, self
).get_query_set().filter(
501 class Actifs(models
.Manager
):
503 def get_query_set(self
):
504 return super(Implantation
.Managers
.Actifs
, self
).get_query_set().filter(actif
=True)
506 objects
= models
.Manager()
507 ouvertes
= Managers
.Ouvertes()
508 actifs
= Managers
.Actifs()
512 db_table
= u
'ref_implantation'
515 def __unicode__(self
):
516 return "%s (%d)" % (self
.nom
, self
.id)
519 class Pays(models
.Model
):
520 """Pays (donnée de référence, source: SQI). Liste AUF basée sur la liste ISO-3166-1. """
521 code
= models
.CharField(max_length
=2, unique
=True)
522 code_iso3
= models
.CharField(max_length
=3, unique
=True)
523 nom
= models
.CharField(max_length
=255)
524 region
= models
.ForeignKey('Region', db_column
='region')
525 code_bureau
= models
.ForeignKey('Bureau', to_field
='code',
526 db_column
='code_bureau', blank
=True,
528 nord_sud
= models
.CharField(max_length
=255, blank
=True, null
=True)
529 developpement
= models
.CharField(max_length
=255, blank
=True, null
=True)
530 monnaie
= models
.CharField(max_length
=255, blank
=True, null
=True)
532 actif
= models
.BooleanField()
535 db_table
= u
'ref_pays'
537 verbose_name
= u
"pays"
538 verbose_name_plural
= u
"pays"
540 def __unicode__(self
):
541 return "%s (%s)" % (self
.nom
, self
.code
)
544 class EtablissementManager(models
.Manager
):
546 def get_query_set(self
):
547 qs
= super(EtablissementManager
, self
).get_query_set()
548 return qs
.select_related('pays')
551 class EtablissementBase(models
.Model
):
553 Établissement (donnée de référence, source: GDE).
554 Un établissement peut être une université, un centre de recherche, un réseau d'établissement...
555 Un établissement peut être membre de l'AUF ou non.
557 MEMBRE_STATUT_CHOICES
= (
563 ('ESR', "Établissement d'enseignement supérieur et de recherche"),
564 ('CIR', "Centre ou institution de recherche"),
569 nom
= models
.CharField(max_length
=255)
570 pays
= models
.ForeignKey('Pays', to_field
='code', db_column
='pays',
572 region
= models
.ForeignKey('Region', db_column
='region', blank
=True,
573 null
=True, related_name
='+', verbose_name
='région')
574 implantation
= models
.ForeignKey('Implantation',
575 db_column
='implantation',
576 related_name
='+', blank
=True, null
=True)
579 membre
= models
.BooleanField()
580 membre_adhesion_date
= models
.DateField(null
=True, blank
=True,
581 verbose_name
="date d'adhésion")
582 statut
= models
.CharField(max_length
=1, choices
=MEMBRE_STATUT_CHOICES
,
583 blank
=True, null
=True)
584 qualite
= models
.CharField(max_length
=3, choices
=QUALITE_CHOICES
,
585 verbose_name
="qualité", blank
=True,
589 responsable_genre
= models
.CharField(max_length
=1, blank
=True,
590 verbose_name
='genre')
591 responsable_nom
= models
.CharField(max_length
=255, blank
=True,
593 responsable_prenom
= models
.CharField(max_length
=255, blank
=True,
594 verbose_name
='prénom')
597 adresse
= models
.CharField(max_length
=255, blank
=True)
598 code_postal
= models
.CharField(max_length
=20, blank
=True,
599 verbose_name
='code postal')
600 cedex
= models
.CharField(max_length
=20, blank
=True, verbose_name
='CEDEX')
601 ville
= models
.CharField(max_length
=255, blank
=True)
602 province
= models
.CharField(max_length
=255, blank
=True)
603 telephone
= models
.CharField(max_length
=255, blank
=True,
604 verbose_name
='téléphone')
605 fax
= models
.CharField(max_length
=255, blank
=True)
606 url
= models
.URLField(verify_exists
=False, max_length
=255, null
=True,
607 blank
=True, verbose_name
='URL')
610 actif
= models
.BooleanField(default
=True)
611 date_modification
= models
.DateField(verbose_name
='date de modification',
612 blank
=True, null
=True)
613 commentaire
= models
.TextField(blank
=True)
616 objects
= EtablissementManager()
620 ordering
= ['pays__nom', 'nom']
622 def __unicode__(self
):
623 return "%s - %s" % (self
.pays
.nom
, self
.nom
)
626 class Etablissement(EtablissementBase
):
628 class Meta(EtablissementBase
.Meta
):
629 db_table
= u
'ref_etablissement'