Champ EmailField sur chercheur et unique=True
[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
AJ
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
9af73c99 31class Utilisateur(Personne):
8468d461 32 password = models.CharField (max_length=35, verbose_name = 'Mot de passe')
9af73c99 33
00755d9b 34FONCTION_CHOICES = (('Professeur', 'Professeur'), ('Chercheur', 'Chercheur'), ('Chercheur_independant', 'Chercheur indépendant'), ('Doctorant', 'Doctorant'))
932eef9a
AJ
35class Chercheur(models.Model):
36 id = models.AutoField(primary_key=True, db_column='id')
73cabd75 37 personne = models.ForeignKey('Personne', db_column='personne')
00755d9b
AJ
38 nationalite = models.ForeignKey(Pays, null = True, db_column='nationalite', to_field='code',
39 verbose_name = 'Nationalité', related_name='nationalite')
7c596de2 40 fonction = models.CharField(max_length=36, choices=FONCTION_CHOICES)
00755d9b 41 diplome = models.CharField(max_length=255, null=True,
7c596de2 42 verbose_name = 'Diplôme le plus élevé')
73cabd75 43 etablissement = models.ForeignKey(Etablissement, db_column='etablissement', null=True, blank=True)
00755d9b
AJ
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')
7c596de2 49 #Domaine
00755d9b 50 thematique = models.ForeignKey(Thematique, db_column='thematique', null=True, verbose_name='Thematique')
73cabd75 51
7c596de2 52 mots_cles = models.CharField(max_length=255, null=True, blank=True,
00755d9b 53 verbose_name='Mots-clés')
73cabd75
AJ
54 discipline = models.ForeignKey(Discipline, db_column='discipline', null=True, blank=True,
55 verbose_name='Champ disciplinaire')
7c596de2 56 expertise = models.TextField(null=True, blank=True, verbose_name='Domaine d\'expertise et thèmes de recherche')
00755d9b 57 url_site_web = models.URLField(max_length=255, null=True, blank=True,
7c596de2 58 verbose_name='Adresse site Internet personnel')
00755d9b
AJ
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
73cabd75 66 groupes = models.ManyToManyField('Groupe', through='ChercheurGroupe', blank=True, verbose_name = 'Domaines de recherche')
932eef9a 67
00755d9b
AJ
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')
5ecd9e43 75
00755d9b
AJ
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
5ecd9e43 88 actif = models.BooleanField(editable = False)
00755d9b
AJ
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
588d6b93 92 def __unicode__(self):
221f4f6c 93 return u"%s %s" % (self.personne.nom.upper(), self.personne.prenom.title())
588d6b93 94
00755d9b
AJ
95class 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')
6befc7c9
AJ
104 #Migration des publications depuis l'ancien repertoire de chercheurs
105 publication_affichage = models.TextField(verbose_name = 'Publication', null = True,
106 blank = True)
5ecd9e43 107 actif = models.BooleanField(editable = False, db_column='actif')
932eef9a
AJ
108
109class Groupe(models.Model):
110 id = models.AutoField(primary_key=True, db_column='id')
111 nom = models.CharField(max_length=255, db_column='nom')
00755d9b
AJ
112 url = models.URLField(max_length=255, null=True, blank=True,
113 verbose_name='Site web')
114 liste_diffusion = models.URLField(max_length=255, null=True, blank=True,
115 verbose_name='Liste de diffusion')
116 bulletin = models.URLField(max_length=255, null=True, blank=True,
117 verbose_name='Bulletin')
932eef9a
AJ
118 actif = models.BooleanField(editable = False, db_column='actif')
119
120 def __unicode__(self):
121 return u"%s" % (self.nom)
122
123class ChercheurGroupe(models.Model):
73cabd75
AJ
124 id = models.AutoField(primary_key=True, db_column='id')
125 chercheur = models.ForeignKey('Chercheur', db_column='chercheur')
126 groupe = models.ForeignKey('Groupe', db_column='groupe')
00755d9b
AJ
127 date_inscription = models.DateField(auto_now_add=True)
128 date_modification = models.DateField(auto_now=True)
5ecd9e43 129 actif = models.BooleanField(editable = False, db_column='actif')