Redmine #2774
authorJean-Philippe Caissy <jpcaissy@piji.ca>
Wed, 14 Mar 2012 14:55:13 +0000 (09:55 -0500)
committerJean-Philippe Caissy <jpcaissy@piji.ca>
Wed, 14 Mar 2012 14:55:13 +0000 (09:55 -0500)
project/rh/graph.py

index bb17ee5..2337aa2 100644 (file)
@@ -10,10 +10,12 @@ from rh import models as rh
 
 def bind_poste_to_graph(graph, postes_by_id):
     for n in graph.nodes():
-        p = postes_by_id[int(n)]
         try:
-            d = rh.Dossier.objects.select_related('employe').filter((Q(date_fin__gt=date.today()) | Q(date_fin=None)) & (Q(date_debut__lt=date.today()) | Q(date_debut=None)) & Q(poste=p)).exclude(supprime=True).all()[0]
-
+            d = rh.Dossier.objects.select_related('employe').filter(
+                    (Q(date_fin__gt=date.today()) | Q(date_fin=None)) &
+                    (Q(date_debut__lt=date.today()) | Q(date_debut=None)) &
+                    Q(poste__id=n)
+            ).exclude(supprime=True).all()[0]
 
             label = u"%s\\n[%s] %s\\n%s" % (d.poste.nom, d.employe_id, "%s %s" %
                     (d.employe.nom.upper(), d.employe.prenom),
@@ -24,7 +26,7 @@ def bind_poste_to_graph(graph, postes_by_id):
             n.attr['style'] = 'filled'
 
         n.attr['label'] = label.encode('ascii', 'xmlcharrefreplace')
-        n.attr['href'] = reverse("admin:rh_poste_change", args=(d.poste_id,))
+        n.attr['href'] = reverse("admin:rh_poste_change", args=(n,))
 
     return graph