8d02f942f9bf1cbf31c5cc60ef06b106e82d7518
[auf_savoirs_en_partage_django.git] / auf_savoirs_en_partage / chercheurs / models.py
1 # -*- encoding: utf-8 -*-
2 from django.db import models
3 from datamaster_modeles.models import *
4 from auf_references_modeles.models import Thematique
5 from savoirs.models import Discipline
6
7 GENRE_CHOICES = (('m', 'Homme'), ('f', 'Femme'))
8 class Personne(models.Model):
9
10 id = models.AutoField(primary_key=True)
11 salutation = models.CharField(max_length=128, null = True, blank = True)
12 nom = models.CharField(max_length=255)
13 prenom = models.CharField(max_length=128, verbose_name = 'Prénom')
14 courriel = models.CharField(max_length=128)
15 fonction = models.CharField(max_length=128, null = True, blank = True)
16 sousfonction = models.CharField(max_length=128, null = True, blank = True,
17 verbose_name = 'Sous-fonction')
18 mobile = models.CharField(max_length=32, null = True, blank = True,
19 verbose_name = 'Numéro de téléphone portable ')
20 genre = models.CharField(max_length=1, choices=GENRE_CHOICES)
21 commentaire = models.TextField(verbose_name = 'Commentaires', null = True,
22 blank = True)
23 actif = models.BooleanField(editable = False)
24
25 def __unicode__(self):
26 return u"%s %s, %s" % (self.prenom, self.nom, self.courriel)
27
28 class Meta:
29 ordering = ["prenom", "nom"]
30
31 class Utilisateur(Personne):
32 password = models.CharField (max_length=35, verbose_name = 'Mot de passe')
33
34 FONCTION_CHOICES = (('Professeur', 'Professeur'), ('Chercheur', 'Chercheur'), ('Chercheur_independant', 'Chercheur indépendant'), ('Doctorant', 'Doctorant'))
35 class Chercheur(models.Model):
36 id = models.AutoField(primary_key=True, db_column='id')
37 personne = models.ForeignKey('Personne', db_column='personne')
38 nationalite = models.ForeignKey(Pays, null = True, db_column='nationalite', to_field='code',
39 verbose_name = 'Nationalité', related_name='nationalite')
40 fonction = models.CharField(max_length=36, choices=FONCTION_CHOICES)
41 diplome = models.CharField(max_length=255, null=True,
42 verbose_name = 'Diplôme le plus élevé')
43 etablissement = models.ForeignKey(Etablissement, db_column='etablissement', null=True, blank=True)
44 etablissement_autre_nom = models.CharField(max_length=255, null=True, blank=True,
45 verbose_name = 'Autre établissement')
46 etablissement_autre_pays = models.ForeignKey(Pays, null = True, blank=True, db_column='etablissement_autre_pays',
47 to_field='code', related_name='etablissement_autre_pays',
48 verbose_name = 'Pays de l\'établissement')
49 #Domaine
50 thematique = models.ForeignKey(Thematique, db_column='thematique', null=True, verbose_name='Thematique')
51
52 mots_cles = models.CharField(max_length=255, null=True, blank=True,
53 verbose_name='Mots-clés')
54 discipline = models.ForeignKey(Discipline, db_column='discipline', null=True, blank=True,
55 verbose_name='Champ disciplinaire')
56 expertise = models.TextField(null=True, blank=True, verbose_name='Domaine d\'expertise et thèmes de recherche')
57 url_site_web = models.URLField(max_length=255, null=True, blank=True,
58 verbose_name='Adresse site Internet personnel')
59 url_blog = models.URLField(max_length=255, null=True, blank=True,
60 verbose_name='Blog')
61 url_facebook = models.URLField(max_length=255, null=True, blank=True,
62 verbose_name='Facebook')
63 url_linkedin = models.URLField(max_length=255, null=True, blank=True,
64 verbose_name='Linkedin')
65
66 groupes = models.ManyToManyField('Groupe', through='ChercheurGroupe', blank=True, verbose_name = 'Domaines de recherche')
67
68 #Refactoring, mettre les publications comme etant des many2many;
69 publication1 = models.ForeignKey('Publication', db_column='publication1', null=True, blank=True, related_name='publication1', verbose_name = 'Publication 1')
70 publication2 = models.ForeignKey('Publication', db_column='publication2', null=True, blank=True, related_name='publication2', verbose_name = 'Publication 2')
71 publication3 = models.ForeignKey('Publication', db_column='publication3', null=True, blank=True, related_name='publication3', verbose_name = 'Publication 3')
72 publication4 = models.ForeignKey('Publication', db_column='publication4', null=True, blank=True, related_name='publication4', verbose_name = 'Publication 4')
73
74 these = models.ForeignKey('Publication', db_column='these', null=True, blank=True, related_name='These')
75
76 #communication_annee
77 #communication_titre
78 #communication_nom_manifestation_scientifique
79 #communication_lieu
80 #communication_date
81
82 #laboratoire_nom =
83 #laboratoire_etablissement =
84 #laboratoire_pays =
85 #laboratoire_url=
86
87 #meta
88 actif = models.BooleanField(editable = False)
89 date_creation = models.DateField(auto_now_add=True, db_column='date_creation')
90 date_modification = models.DateField(auto_now=True, db_column='date_modification')
91
92 def __unicode__(self):
93 return u"%s %s" % (self.personne.nom.upper(), self.personne.prenom.title())
94
95 class Publication(models.Model):
96 id = models.AutoField(primary_key=True, db_column='id')
97 titre = models.CharField(max_length=255, db_column='titre', null=True, blank=True, verbose_name = 'Titre')
98 annee = models.IntegerField(db_column='annee', null=True, blank=True, verbose_name='Année de publication')
99 revue = models.CharField(max_length=255, db_column='revue', null=True, blank=True, verbose_name = 'Revue')
100 editeur = models.CharField(max_length=255, db_column='editeur', null=True, blank=True, verbose_name = 'Éditeur')
101 lieu_edition = models.CharField(max_length=255, db_column='lieu_edition', null=True, blank=True, verbose_name = 'Lieu d\'édition')
102 nb_pages = models.CharField(max_length=255, db_column='nb_pages', null=True, blank=True, verbose_name = 'Nombre de pages')
103 url = models.CharField(max_length=255, db_column='url', null=True, blank=True, verbose_name = 'Lien vers la publication')
104 actif = models.BooleanField(editable = False, db_column='actif')
105
106 class Groupe(models.Model):
107 id = models.AutoField(primary_key=True, db_column='id')
108 nom = models.CharField(max_length=255, db_column='nom')
109 url = models.URLField(max_length=255, null=True, blank=True,
110 verbose_name='Site web')
111 liste_diffusion = models.URLField(max_length=255, null=True, blank=True,
112 verbose_name='Liste de diffusion')
113 bulletin = models.URLField(max_length=255, null=True, blank=True,
114 verbose_name='Bulletin')
115 actif = models.BooleanField(editable = False, db_column='actif')
116
117 def __unicode__(self):
118 return u"%s" % (self.nom)
119
120 class ChercheurGroupe(models.Model):
121 id = models.AutoField(primary_key=True, db_column='id')
122 chercheur = models.ForeignKey('Chercheur', db_column='chercheur')
123 groupe = models.ForeignKey('Groupe', db_column='groupe')
124 date_inscription = models.DateField(auto_now_add=True)
125 date_modification = models.DateField(auto_now=True)
126 actif = models.BooleanField(editable = False, db_column='actif')