Desactivation mots-cles recherche chercheurs
[auf_savoirs_en_partage_django.git] / auf_savoirs_en_partage / chercheurs / views.py
index 3392461..ff95ee3 100644 (file)
@@ -19,7 +19,7 @@ def chercheur_queryset (request):
     if simpleForm.is_valid ():
         pays = simpleForm.cleaned_data["pays"]
         if pays:
-            list = list.filter (pays = pays.pk)
+            list = list.filter (nationalite = pays.pk)
         fonction = simpleForm.cleaned_data["fonction"]
         if fonction:
             list = list.filter (fonction = fonction)
@@ -29,9 +29,9 @@ def chercheur_queryset (request):
         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)
+        #mots_cles = simpleForm.cleaned_data["mots_cles"]
+        #if mots_cles:
+        #    list = list.filter (personne__nom__icontains=mots_cles)
     return list
     
 def repertoire(request):
@@ -69,16 +69,16 @@ def inscription(request):
                 discipline_form = DisciplineForm (request.POST, prefix="discipline", instance=c)
                 
                 if etablissement_form.is_valid() and discipline_form.is_valid():       
-                    if publication1_form.is_valid():
+                    if publication1_form.is_valid() and publication1_form.cleaned_data['titre']:
                        pub = publication1_form.save()
                        c.publication1 = pub
-                    if publication2_form.is_valid():
+                    if publication2_form.is_valid() and publication2_form.cleaned_data['titre']:
                        pub = publication2_form.save()
                        c.publication2 = pub   
-                    if publication3_form.is_valid():
+                    if publication3_form.is_valid() and publication3_form.cleaned_data['titre']:
                        pub = publication3_form.save()
                        c.publication3 = pub    
-                    if publication4_form.is_valid():
+                    if publication4_form.is_valid() and publication4_form.cleaned_data['titre']:
                        pub = publication4_form.save()
                        c.publication4 = pub    
                     etablissement_form.save(commit=False)
@@ -123,13 +123,47 @@ def edit(request):
     context_instance = RequestContext(request)
     chercheur = context_instance['user_chercheur']    
     if request.method == 'POST':
-        personne_form = PersonneEditForm(request.POST, prefix="personne", instance=chercheur.personne)  
-        personne_form.save()
+        personne_form = PersonneEditForm(request.POST, prefix="personne", instance=chercheur.personne)
+        chercheur_form = ChercheurForm (request.POST, prefix="chercheur", instance=chercheur)
+        etablissement_form = EtablissementForm(request.POST, prefix="etablissement", instance=chercheur)
+        etablissement_autre_form = EtablissementAutreForm(request.POST, prefix="etablissement_autre", instance=chercheur)
+        discipline_form = DisciplineForm(request.POST, prefix="discipline", instance=chercheur)
+        publication1_form = PublicationForm(request.POST, prefix="publication1", instance=chercheur.publication1)
+        publication2_form = PublicationForm(request.POST, prefix="publication2", instance=chercheur.publication2) 
+        publication3_form = PublicationForm(request.POST, prefix="publication3", instance=chercheur.publication3) 
+        publication4_form = PublicationForm(request.POST, prefix="publication4", instance=chercheur.publication4)
+        
+
+        if( personne_form.is_valid() and discipline_form.is_valid() and publication1_form.is_valid() and publication2_form.is_valid() and publication3_form.is_valid() and publication4_form.is_valid() and chercheur_form.is_valid() ):
+            personne_form.save()
+            chercheur_form.save()
+            discipline_form.save()
+            publication1_form.save()
+            publication2_form.save()
+            publication3_form.save()
+            publication4_form.save()
     else:
-        personne_form = PersonneEditForm(prefix="personne", instance=chercheur.personne)        
+        personne_form = PersonneEditForm(prefix="personne", instance=chercheur.personne) 
+        chercheur_form = ChercheurForm (prefix="chercheur", instance=chercheur)
+        etablissement_form = EtablissementForm(prefix="etablissement", instance=chercheur)
+        etablissement_autre_form = EtablissementAutreForm(prefix="etablissement_autre", instance=chercheur)
+        discipline_form = DisciplineForm(prefix="discipline", instance=chercheur)
+        publication1_form = PublicationForm(prefix="publication1", instance=chercheur.publication1)
+        publication2_form = PublicationForm(prefix="publication2", instance=chercheur.publication2) 
+        publication3_form = PublicationForm(prefix="publication3", instance=chercheur.publication3) 
+        publication4_form = PublicationForm(prefix="publication4", instance=chercheur.publication4)    
+    #import pdb; pdb.set_trace()    
         
     variables = { 'chercheur': chercheur,
                   'personne_form':personne_form,
+                  'chercheur_form': chercheur_form,
+                  'etablissement_form': etablissement_form,
+                  'discipline_form': discipline_form,
+                  'etablissement_autre_form': etablissement_autre_form,
+                  'publication1_form': publication1_form,
+                  'publication2_form': publication2_form,
+                  'publication3_form': publication3_form,
+                  'publication4_form': publication4_form,
                 }
     return render_to_response ("chercheurs/edit.html", \
             Context (variables),