fix ajax for salaire proposition
[auf_rh_dae.git] / project / rh / graph.py
... / ...
CommitLineData
1from datetime import date
2from django.db.models import Q
3from django.core.urlresolvers import reverse
4
5from rh import models as rh
6
7def bind_poste_to_graph(graph, postes_by_id):
8 for n in graph.nodes():
9 p = postes_by_id[int(n)]
10 try:
11 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]
12
13
14 label = u"%s\\n[%s] %s\\n%s" % (d.poste.nom, d.employe_id, "%s %s" %
15 (d.employe.nom.upper(), d.employe.prenom),
16 d.poste.implantation)
17 except IndexError:
18 label = u"%s\\n---\\n%s" % (d.poste.nom, d.poste.implantation)
19 n.attr['fillcolor'] = 'azure4'
20 n.attr['style'] = 'filled'
21
22 n.attr['label'] = label.encode('ascii', 'xmlcharrefreplace')
23 n.attr['href'] = reverse("admin:rh_employe_change", args=(d.employe_id,))
24
25 return graph