Organigramme en svg
authorJean-Philippe Caissy <jpcaissy@piji.ca>
Thu, 1 Mar 2012 22:21:27 +0000 (16:21 -0600)
committerJean-Philippe Caissy <jpcaissy@piji.ca>
Thu, 1 Mar 2012 22:21:27 +0000 (16:21 -0600)
project/rh/templates/rh/organigrammes/employe.html
project/rh/views.py

index d9c4e56..221d7c5 100644 (file)
@@ -1,3 +1 @@
-{% if png %}
-<img src="data:image/png;base64,{{ png }}" />
-{% endif %}
+{{ svg|safe }}
index 3972a71..d85ab61 100644 (file)
@@ -10,6 +10,7 @@ from django.utils.encoding import smart_str
 from django.shortcuts import redirect, render_to_response, get_object_or_404
 from django.template import RequestContext
 from django.http import Http404
+from django.core.urlresolvers import reverse
 
 from datamaster_modeles import models as ref
 from project.lib import get_employe_from_id
@@ -474,6 +475,8 @@ def employe_apercu(request, employe_id):
     }
     return render_to_response('admin/rh/employe/apercu.html', c, RequestContext(request))
 
+@login_required
+@drh_or_admin_required
 def organigrammes_employe(request, id):
 
     poste = get_object_or_404(rh.Poste, pk=id)
@@ -495,17 +498,18 @@ def organigrammes_employe(request, id):
         for n in a.nodes():
             p = postes_by_id[int(n)]
             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).exclude(poste__responsable=None).all()[0]
-
-            n.attr['label'] = u"%s %s\\n%s\\n%s" % (d.id, d.poste.nom, "%s %s" % (d.employe.nom.upper(), d.employe.prenom), d.poste.implantation)
+            n.attr['label'] = "%s %s\\n%s\\n%s" % (d.id, d.poste.nom, "%s %s" % (d.employe.nom.upper(), d.employe.prenom), d.poste.implantation)
+            #n.attr['label'] = str(n.attr['label'].encode('ascii', 'xmlcharrefreplace'))
+            n.attr['href'] = reverse("admin:rh_employe_change", args=(d.employe_id,))
 
         a.graph_attr['normalize'] = True
         a.graph_attr['level'] = 2
         a.layout(prog='dot')
 
-        png = a.draw(format='png')
+        svg = a.draw(format='svg')
 
         c = {
-            'png': b64encode(png)
+            'svg': svg
         }
     else:
         c = {}