ebauche espace chercheur
[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, blank = True)
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)
33
34 FONCTION_CHOICES = (('Professeur', 'Professeur'), ('Chercheur', 'Chercheur'), ('Doctorant', 'Doctorant'), ('Autre', 'Autre'))
35 class Chercheur(models.Model):
36 id = models.AutoField(primary_key=True, db_column='id')
37 personne = models.ForeignKey('Personne', db_column='personne')
38 pays = models.ForeignKey(Pays, null = True, db_column='pays', to_field='code', verbose_name = 'Nationalité')
39 fonction = models.CharField(max_length=36, choices=FONCTION_CHOICES)
40 scolarite = models.CharField(max_length=255, null=True,
41 verbose_name = 'Diplôme le plus élevé')
42 etablissement = models.ForeignKey(Etablissement, db_column='etablissement', null=True, blank=True)
43 #Domaine
44 thematique = models.ForeignKey(Thematique, db_column='thematique', null=True)
45
46 mots_cles = models.CharField(max_length=255, null=True, blank=True,
47 verbose_name='Mots-clés')
48 these = models.CharField(max_length=255, null=True, blank=True,
49 verbose_name='Thèse')
50 discipline = models.ForeignKey(Discipline, db_column='discipline', null=True, blank=True,
51 verbose_name='Champ disciplinaire')
52 expertise = models.TextField(null=True, blank=True, verbose_name='Domaine d\'expertise et thèmes de recherche')
53 url = models.URLField(max_length=255, null=True, blank=True,
54 verbose_name='Adresse site Internet personnel')
55 publication1 = models.CharField(max_length=255, null=True, blank=True,
56 verbose_name = 'Publication 1')
57 publication2 = models.CharField(max_length=255, null=True, blank=True,
58 verbose_name = 'Publication 2')
59 publication3 = models.CharField(max_length=255, null=True, blank=True,
60 verbose_name = 'Publication 3')
61 publication4 = models.CharField(max_length=255, null=True, blank=True,
62 verbose_name = 'Publication 4')
63 groupes = models.ManyToManyField('Groupe', through='ChercheurGroupe', blank=True, verbose_name = 'Domaines de recherche')
64 actif = models.BooleanField(editable = False)
65
66 def __unicode__(self):
67 return u"%s %s" % (self.personne.nom.upper(), self.personne.prenom.title())
68
69
70 class Groupe(models.Model):
71 id = models.AutoField(primary_key=True, db_column='id')
72 nom = models.CharField(max_length=255, db_column='nom')
73 actif = models.BooleanField(editable = False, db_column='actif')
74
75 def __unicode__(self):
76 return u"%s" % (self.nom)
77
78 class ChercheurGroupe(models.Model):
79 id = models.AutoField(primary_key=True, db_column='id')
80 chercheur = models.ForeignKey('Chercheur', db_column='chercheur')
81 groupe = models.ForeignKey('Groupe', db_column='groupe')
82 date_inscription = models.DateField(auto_now=True)