from django import forms
from models import *
+
class PersonneForm(forms.ModelForm):
class Meta:
model = Personne
class Meta:
model = Chercheur
fields = ('discipline', 'expertise', 'mots_cles', 'url', 'publication1', 'publication2', 'publication3')
+
+
+class RepertoireSearchForm (forms.Form):
+ mots_cles = forms.CharField (required = False, label="Mots-clés")
+ discipline = forms.ModelChoiceField(queryset=Discipline.objects.all(), required=False, label="Champ disciplinaire", empty_label="Tous")
+ fonction = forms.ChoiceField(choices=(('','Tous'),)+FONCTION_CHOICES, required=False, label="Fonction")
+ pays = forms.ModelChoiceField(queryset=Pays.objects.all().order_by("nom"), required=False, label="Localisation", empty_label="Tous")
+ genre = forms.ChoiceField(choices=(('','Tous'),)+GENRE_CHOICES, required=False, label="Sexe")
from datamaster_modeles.models import *
from savoirs.models import Discipline
-GENRE_CHOICES = (('H', 'Homme'), ('F', 'Femme'))
+GENRE_CHOICES = (('m', 'Homme'), ('f', 'Femme'))
class Personne(models.Model):
id = models.AutoField(primary_key=True)
from auf_references_client.models import Discipline, TypeImplantation
from models import Personne
+
+def chercheur_queryset (request):
+ list = Chercheur.objects.order_by("id")
+ pays = ""
+
+ simpleForm = RepertoireSearchForm (request.GET)
+ if simpleForm.is_valid ():
+ pays = simpleForm.cleaned_data["pays"]
+ if pays:
+ list = list.filter (pays = pays.pk)
+ fonction = simpleForm.cleaned_data["fonction"]
+ if fonction:
+ list = list.filter (fonction = fonction)
+ genre = simpleForm.cleaned_data["genre"]
+ if genre:
+ list = list.filter (personne__genre=genre)
+ discipline = simpleForm.cleaned_data["discipline"]
+ if discipline:
+ list = list.filter (discipline=discipline)
+ mots_cles = simpleForm.cleaned_data["mots_cles"]
+ if mots_cles:
+ list = list.filter (personne__nom__icontains=mots_cles)
+ return list
+
def repertoire(request):
"""Mock up du répertoire"""
- chercheurs = Chercheur.objects.all()
+
+ chercheurs = chercheur_queryset (request)
+ repertoire_form = RepertoireSearchForm (request.GET)
+
nb_chercheurs = chercheurs.count()
variables = { 'chercheurs': chercheurs,
'nb_chercheurs': nb_chercheurs,
+ 'repertoire_form': repertoire_form,
}
return render_to_response ("chercheurs/repertoire.html", \
Context (variables),
.box { padding:0 0 20px 0; }
.lbl {color: #97012c; }
+.centre { text-align:center }
+
#fond {padding:0; margin:0; display:block; position:relative; width:100%; height:auto !important; height:100%; min-height:100%; background: url(../img/background-fond.jpg) no-repeat 50% 0; text-align:left;}
#enrobage {padding:0; margin:0 auto; display:block; position:relative; width:960px; height:auto !important; height:100%; min-height:100%;}
.form p { margin-bottom: 2px; }
.form tr:first-child { border-top: none; }
-.odd { background: #f0f0f0; }
+.odd { background: #ddd; }
+
+#repertoire { border:1px solid #bbb; padding:20px; margin: 10px; width:95% }
+#repertoire th, td { padding:5px }
{% autosort chercheurs %}
{% autopaginate chercheurs 20 %}
-<h4>Chercheurs</h4>
+<h4>Répertoire des chercheurs</h4>
<div class="contenu-wrapper">
-<strong>{{nb_chercheurs}} chercheurs</strong>
-{% paginate %}
-<table>
+
+<form method="get" action="">
+ <table id="repertoire_recherche">
+ {{repertoire_form.as_table}}
+ <tr>
+ <td colspan="2" class="Lib">
+ <input type="submit" class="bouton" value="Rechercher" />
+ </td>
+ </tr>
+ </table>
+</form>
+
+
+<p><strong>{{nb_chercheurs}} chercheurs correspondant à votre recherche :</strong></p>
+<div class="centre">{% paginate %}</div>
+<table id="repertoire">
<tr>
<th>{% anchor personne__nom Nom %}</th>
<th>{% anchor etablissement__nom Établissement %}</th>
<th>{% anchor pays__nom Localisation %}</th>
</tr>
{% for chercheur in chercheurs %}
- <tr>
+ <tr class="{% cycle 'odd' 'notodd' %}">
<td><a href="{% url chercheurs.views.retrieve chercheur.id %}">{{ chercheur }}</a></td>
<td>{{ chercheur.etablissement }}</td>
<td>{{ chercheur.pays }}</td>
</tr>
{% endfor %}
</table>
-{% paginate %}
+<div class="centre">{% paginate %}</div>
</div>
{% extends "container_base.html" %}
{% block contenu %}
-
{% include "chercheurs/rechercher.html" %}
-
{% endblock %}