fix creation justifications
authorOlivier Larchevêque <olivier.larcheveque@auf.org>
Fri, 15 Apr 2011 18:49:44 +0000 (14:49 -0400)
committerOlivier Larchevêque <olivier.larcheveque@auf.org>
Fri, 15 Apr 2011 18:49:44 +0000 (14:49 -0400)
project/dae/forms.py

index 69f10e4..543f384 100644 (file)
@@ -31,7 +31,7 @@ class JustificationNouvelEmployeForm(inlineformset_factory(dae.Dossier,
     def __init__(self, *args, **kwargs):
         instance = kwargs['instance']
         if instance.id:
-            q_ids = [q.id for q in instance.justificationnouvelemploye_set.all()]
+            q_ids = [j.question.id for j in instance.justificationnouvelemploye_set.filter(dossier=instance)]
             for q in dae.JustificationQuestion.objects.filter(type="N"):
                 if q.id in q_ids:
                     continue
@@ -53,7 +53,7 @@ class JustificationAutreEmployeForm(inlineformset_factory(dae.Dossier,
     def __init__(self, *args, **kwargs):
         instance = kwargs['instance']
         if instance.id:
-            q_ids = [q.id for q in instance.justificationautreemploye_set.all()]
+            q_ids = [j.question.id for j in instance.justificationautreemploye_set.filter(dossier=instance)]
             for q in dae.JustificationQuestion.objects.filter(type="R"):
                 if q.id in q_ids:
                     continue