From 7c596de29cd7161255d023248e4ad279a364f61e Mon Sep 17 00:00:00 2001 From: Ali Jetha Date: Thu, 9 Sep 2010 15:35:57 -0400 Subject: [PATCH] chercheur model avance --- auf_savoirs_en_partage/chercheurs/forms.py | 12 +++++- auf_savoirs_en_partage/chercheurs/models.py | 43 ++++++++++++++++++-- auf_savoirs_en_partage/chercheurs/views.py | 20 +++++++-- .../templates/chercheurs/inscription.html | 11 +++++ 4 files changed, 79 insertions(+), 7 deletions(-) diff --git a/auf_savoirs_en_partage/chercheurs/forms.py b/auf_savoirs_en_partage/chercheurs/forms.py index fa2ec47..0e48451 100644 --- a/auf_savoirs_en_partage/chercheurs/forms.py +++ b/auf_savoirs_en_partage/chercheurs/forms.py @@ -10,4 +10,14 @@ class PersonneForm(forms.ModelForm): class ChercheurForm(forms.ModelForm): class Meta: model = Chercheur - fields = ('pays', 'discipline', 'groupes') + fields = ('pays', 'groupes') + +class EtablissementForm(forms.ModelForm): + class Meta: + model = Chercheur + fields = ('etablissement',) + +class DisciplineForm(forms.ModelForm): + class Meta: + model = Chercheur + fields = ('discipline', 'expertise', 'url', 'publication1', 'publication2', 'publication3') diff --git a/auf_savoirs_en_partage/chercheurs/models.py b/auf_savoirs_en_partage/chercheurs/models.py index 8754813..d8dca17 100644 --- a/auf_savoirs_en_partage/chercheurs/models.py +++ b/auf_savoirs_en_partage/chercheurs/models.py @@ -1,6 +1,6 @@ # -*- encoding: utf-8 -*- from django.db import models -from auf_references_client.models import Discipline, Pays +from auf_references_client.models import Discipline, Pays, Etablissement, Thematique GENRE_CHOICES = (('H', 'Homme'), ('F', 'Femme')) class Personne(models.Model): @@ -26,11 +26,48 @@ class Personne(models.Model): class Meta: ordering = ["prenom", "nom"] +FONCTION_CHOICES = (('Professeur', 'Professeur'), ('Chercheur', 'Chercheur'), ('Doctorant', 'Doctorant'), ('Autre', 'Autre')) class Chercheur(models.Model): id = models.AutoField(primary_key=True, db_column='id') personne = models.ForeignKey('Personne') - discipline = models.ForeignKey(Discipline) - pays = models.ForeignKey(Pays) + pays = models.ForeignKey(Pays, null = True, verbose_name = 'Nationalité') + fonction = models.CharField(max_length=36, choices=FONCTION_CHOICES) + scolarite = models.CharField(max_length=255, null=True, + verbose_name = 'Diplôme le plus élevé') + + + etablissement = models.ForeignKey(Etablissement, null=True, blank=True) + + #Domaine + thematique = models.ForeignKey(Thematique, null=True) + + + + mots_cles = models.CharField(max_length=255, null=True, blank=True, + verbose_name='Mots-clés') + these = models.CharField(max_length=255, null=True, blank=True, + verbose_name='Thèse') + + + discipline = models.ForeignKey(Discipline, null=True, + verbose_name='Champ disciplinaire') + expertise = models.TextField(null=True, blank=True, verbose_name='Domaine d\'expertise et thèmes de recherche') + url = models.URLField(max_length=255, null=True, blank=True, + verbose_name='Adresse site Internet personnel') + + publication1 = models.CharField(max_length=255, null=True, + verbose_name = 'Publication 1') + publication2 = models.CharField(max_length=255, null=True, blank=True, + verbose_name = 'Publication 2') + publication3 = models.CharField(max_length=255, null=True, blank=True, + verbose_name = 'Publication 3') + publication4 = models.CharField(max_length=255, null=True, blank=True, + verbose_name = 'Publication 4') + + + + + groupes = models.ManyToManyField('Groupe', through='ChercheurGroupe') actif = models.BooleanField(editable = False) diff --git a/auf_savoirs_en_partage/chercheurs/views.py b/auf_savoirs_en_partage/chercheurs/views.py index c28db11..646ed08 100644 --- a/auf_savoirs_en_partage/chercheurs/views.py +++ b/auf_savoirs_en_partage/chercheurs/views.py @@ -21,18 +21,32 @@ def inscription(request): if request.method == 'POST': personne_form = PersonneForm (request.POST, prefix="personne") chercheur_form = ChercheurForm (request.POST, prefix="chercheur") + etablissement_form = EtablissementForm (request.POST, prefix="etablissement") + discipline_form = DisciplineForm (request.POST, prefix="discipline") + if personne_form.is_valid(): if chercheur_form.is_valid(): - p = personne_form.save() c = chercheur_form.save(commit=False) - c.personne = p - c.save() + + etablissement_form = EtablissementForm (request.POST, prefix="etablissement", instance=c) + discipline_form = DisciplineForm (request.POST, prefix="discipline", instance=c) + + if etablissement_form.is_valid() and discipline_form.is_valid(): + etablissement_form.save(commit=False) + discipline_form.save(commit=False) + p = personne_form.save() + c.personne = p + c.save() else: personne_form = PersonneForm(prefix="personne") chercheur_form = ChercheurForm(prefix="chercheur") + etablissement_form = EtablissementForm(prefix="etablissement") + discipline_form = DisciplineForm(prefix="discipline") variables = { 'personne_form': personne_form, 'chercheur_form': chercheur_form, + 'etablissement_form': etablissement_form, + 'discipline_form': discipline_form, } return render_to_response ("chercheurs/inscription.html", \ diff --git a/auf_savoirs_en_partage/templates/chercheurs/inscription.html b/auf_savoirs_en_partage/templates/chercheurs/inscription.html index 3558436..8a12da4 100644 --- a/auf_savoirs_en_partage/templates/chercheurs/inscription.html +++ b/auf_savoirs_en_partage/templates/chercheurs/inscription.html @@ -18,6 +18,17 @@ Pour vous inscrire au répertoire de chercheurs, vous devez avoir un compte AUF. {% with chercheur_form as form %} {% include "table_form.html" %} {% endwith %} + +
Etablissement de rattachement
+ {% with etablissement_form as form %} + {% include "table_form.html" %} + {% endwith %} + +
Champ disciplinaire, thèmes de recherche & publications
+ {% with discipline_form as form %} + {% include "table_form.html" %} + {% endwith %} +
-- 1.7.10.4