Réparé erreur à la sauvegarde d'un nouveau poste
authorEric Mc Sween <eric.mcsween@auf.org>
Mon, 14 Nov 2011 21:53:49 +0000 (16:53 -0500)
committerEric Mc Sween <eric.mcsween@auf.org>
Mon, 14 Nov 2011 21:53:49 +0000 (16:53 -0500)
project/dae/views.py

index 85549f4..e011ac8 100644 (file)
@@ -148,10 +148,16 @@ def poste(request, key=None):
         form = PosteForm(data, instance=poste, request=request)
         financementForm = FinancementForm(request.POST, instance=poste)
         piecesForm = PostePieceForm(request.POST, request.FILES, instance=poste)
-        comparaisons_formset = PosteComparaisonFormSet(
-            request.POST,
-            queryset=poste.comparaisons_internes.ma_region_ou_service(request.user)
-        )
+        if isinstance(poste, dae.Poste):
+            comparaisons_formset = PosteComparaisonFormSet(
+                request.POST,
+                queryset=poste.comparaisons_internes.ma_region_ou_service(request.user)
+            )
+        else:
+            comparaisons_formset = PosteComparaisonFormSet(
+                request.POST,
+                queryset=dae.PosteComparaison.objects.none()
+            )
         if form.is_valid() and piecesForm.is_valid() and financementForm.is_valid() and \
            comparaisons_formset.is_valid():
             poste = form.save()