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