0f0cf1a248b26191b899c97753ed2c2476b4078f
[auf_rh_dae.git] / project / rh / views.py
1 # -*- encoding: utf-8 -*-
2
3 import urllib
4 from datetime import date
5 from itertools import izip
6 import StringIO
7
8 import pygraphviz as pgv
9 from datamaster_modeles import models as ref
10 from django.core.urlresolvers import reverse
11 from django.db.models import Q
12 from django.utils.encoding import smart_str
13 from django.shortcuts import render_to_response, get_object_or_404
14 from django.template import RequestContext
15 from django.http import HttpResponse
16 from django import forms
17 from django.contrib.auth.decorators import login_required
18 from django.core.servers.basehttp import FileWrapper
19
20 from rh import models as rh
21 from rh.lib import calc_remun
22 from rh.decorators import drh_or_admin_required
23 from rh.templatetags.rapports import SortHeaders
24 from rh.change_list import RechercheTemporelle
25 from rh import graph as rh_graph
26 from rh.masse_salariale import MasseSalariale
27
28 # pas de reference a DAE devrait etre refactorisé
29 from dae.utils import get_employe_from_user
30 from dae.decorators import redirect_interdiction
31 from dae.workflow import grp_drh, grp_correspondants_rh
32 from django.conf import settings
33
34
35 @login_required
36 def profil(request):
37 """Profil personnel de l'employé - éditable"""
38 rc = RequestContext(request)
39 c = {}
40
41 employe = rc['this_employe']
42
43 c['user'] = request.user
44 c['employe'] = employe
45 return render_to_response('rh/profil.html', c, rc)
46
47
48 @login_required
49 def employes_liste(request):
50 """Liste des employés."""
51 today = date.today()
52 employes = rh.Employe.objects \
53 .exclude(dossiers__date_debut__gt=today) \
54 .exclude(dossiers__date_fin__lt=today) \
55 .order_by('nom')
56 c = {
57 'user': request.user,
58 'employes': employes,
59 }
60 return render_to_response('rh/employes_liste.html',
61 c,
62 RequestContext(request))
63
64
65 @login_required
66 def employe(request, id):
67 """Information publique sur un employé."""
68 try:
69 employe = rh.Employe.objects.get(pk=id)
70 except:
71 employe = rh.Employe.objects.none()
72 c = {
73 'user': request.user,
74 'employe': employe,
75 }
76 return render_to_response('rh/employe.html', c, RequestContext(request))
77
78
79 @login_required
80 @drh_or_admin_required
81 def rapports_poste(request):
82
83 lookup_params = dict(request.GET.items())
84
85 for key, value in lookup_params.items():
86 if key == 'o' or key == 'ot':
87 del lookup_params[key]
88 continue
89 if not isinstance(key, str):
90 # 'key' will be used as a keyword argument later, so Python
91 # requires it to be a string.
92 del lookup_params[key]
93 lookup_params[smart_str(key)] = value
94
95 if key == 'comble':
96 del lookup_params[key]
97
98 sort_order = 'ASC' if request.GET.get('ot') == 'asc' else 'DESC'
99
100 postes = rh.Poste.objects.select_related('implantation') \
101 .extra(select={
102 'employe_id':
103 'SELECT GROUP_CONCAT(employe SEPARATOR "|") '
104 'FROM rh_dossier '
105 'WHERE poste = rh_poste.id '
106 'AND rh_dossier.date_fin IS NULL ' + (
107 'ORDER BY employe ' + sort_order
108 if request.GET.get('o') == 'employe_id' else ''
109 )
110 }) \
111 .extra(select={
112 'employe_nom':
113 'SELECT GROUP_CONCAT(rh_employe.nom SEPARATOR "|") '
114 'FROM rh_dossier INNER JOIN rh_employe '
115 'ON rh_dossier.employe = rh_employe.id '
116 'WHERE poste = rh_poste.id '
117 'AND rh_dossier.date_fin IS NULL ' + (
118 'ORDER BY rh_employe.nom ' + sort_order
119 if request.GET.get('o') == 'employe_nom' else ''
120 )
121 }) \
122 .extra(select={
123 'employe_prenom':
124 'SELECT GROUP_CONCAT(rh_employe.prenom SEPARATOR "|") '
125 'FROM rh_dossier INNER JOIN rh_employe '
126 'ON rh_dossier.employe = rh_employe.id '
127 'WHERE poste = rh_poste.id '
128 'AND rh_dossier.date_fin IS NULL ' + (
129 'ORDER BY rh_employe.prenom ' + sort_order
130 if request.GET.get('o') == 'employe_prenom' else ''
131 )
132 })
133
134 postes = postes.filter(**lookup_params)
135 if 'o' in request.GET:
136 postes = postes.order_by(
137 ('-' if sort_order == "DESC" else '') + request.GET['o']
138 )
139
140 out = []
141 for p in postes:
142 out.append({
143 'id': p.id,
144 'nom': p.nom,
145 'implantation': p.implantation,
146 'employes': [] if not p.employe_id else [
147 {'id': id, 'nom': nom, 'prenom': prenom}
148 for id, nom, prenom in izip(
149 p.employe_id.split('|'),
150 p.employe_nom.split('|'),
151 p.employe_prenom.split('|')
152 )
153 ]
154 })
155
156 headers = [
157 ("id", u"# du poste"),
158 ("nom", u"Nom du poste"),
159 ("implantation__id", u"Implantation"),
160 ("employe_nom", u"Nom"),
161 ]
162 h = SortHeaders(request, headers, order_field_type="ot", order_field="o")
163 c = {
164 'title': 'Rapport des postes',
165 'postes': out,
166 'count': len(out),
167 'headers': list(h.headers()),
168 }
169
170 return render_to_response(
171 'rh/rapports/postes.html', c, RequestContext(request)
172 )
173
174
175 @login_required
176 @drh_or_admin_required
177 def rapports_contrat(request):
178 if 'HTTP_REFERER' in request.META.keys():
179 referer = request.META['HTTP_REFERER']
180 referer = "/".join(referer.split('/')[3:])
181 referer = "/%s" % referer.split('?')[0]
182 if referer != reverse('rhr_contrats'):
183 params = request.GET.copy()
184 params.update({'statut': 'Actif'})
185 request.GET = params
186
187 lookup_params = dict(request.GET.items())
188 if 'ot' in lookup_params:
189 del lookup_params['ot']
190 if 'o' in lookup_params:
191 del lookup_params['o']
192
193 for key, value in lookup_params.items():
194 if not isinstance(key, str):
195 # 'key' will be used as a keyword argument later, so Python
196 # requires it to be a string.
197 del lookup_params[key]
198 lookup_params[smart_str(key)] = value
199
200 contrats = rh.Contrat.objects.select_related(
201 'dossier', 'dossier__poste', 'dossier__poste__implantation',
202 'type_contrat', 'dossier__employe'
203 )
204
205 cl = RechercheTemporelle(dict(request.GET.items()), rh.Contrat)
206 lookup_params = cl.purge_params(lookup_params)
207 q_temporel = cl.get_q_temporel(contrats)
208 q = Q(**lookup_params) & q_temporel
209 contrats = contrats.filter(q).exclude(dossier__employe__supprime=1)
210
211 if 'o' in request.GET:
212 contrats = contrats.order_by(
213 ('-' if request.GET.get('ot') == "desc" else '') + request.GET['o']
214 )
215
216 employes = set([c.dossier.employe_id for c in contrats])
217
218 headers = [
219 ("dossier__employe__id", u"# de l'employé"),
220 ("dossier__employe__nom", u"Employé"),
221 ("type_contrat__nom", u"Poste"),
222 ("dossier__poste__implantation__region", u"Région"),
223 ("dossier__poste__implantation", u"Implantation"),
224 ("type_contrat__nom", u"Type de contrat"),
225 ("date_debut", u"Date début"),
226 ("date_fin", u"Date fin"),
227 ]
228 h = SortHeaders(request, headers, order_field_type="ot", order_field="o")
229
230 c = {
231 'cl': cl,
232 'title': 'Rapport des contrats',
233 'contrats': contrats,
234 'count': len(contrats),
235 'count_employe': len(employes),
236 'headers': list(h.headers()),
237 }
238
239 return render_to_response(
240 'rh/rapports/contrats.html', c, RequestContext(request)
241 )
242
243
244 @login_required
245 @drh_or_admin_required
246 def rapports_masse_salariale(request):
247
248 class RechercheTemporelle(forms.Form):
249 CHOICE_ANNEES = range(
250 rh.Remuneration.objects.exclude(date_debut=None)
251 .order_by('date_debut')[0].date_debut.year,
252 date.today().year + 1
253 )
254
255 annee = forms.CharField(
256 initial=date.today().year,
257 widget=forms.Select(
258 choices=((a, a) for a in reversed(CHOICE_ANNEES))
259 )
260 )
261
262 region = forms.CharField(
263 widget=forms.Select(choices=[('', '')] +
264 [(i.id, i) for i in ref.Region.objects.all()]
265 )
266 )
267
268 implantation = forms.CharField(
269 widget=forms.Select(choices=[('', '')] +
270 [(i.id, i) for i in ref.Implantation.objects.all()]
271 )
272 )
273
274 #date_debut = forms.DateField(widget=adminwidgets.AdminDateWidget)
275 #date_fin = forms.DateField(widget=adminwidgets.AdminDateWidget)
276
277 form = RechercheTemporelle(request.GET)
278 get_filtre = [
279 (k, v) for k, v in request.GET.items()
280 if k not in ('date_debut', 'date_fin', 'implantation')
281 ]
282 query_string = urllib.urlencode(get_filtre)
283
284 date_debut = None
285 date_fin = None
286 if request.GET.get('annee', None):
287 date_debut = "01-01-%s" % request.GET.get('annee', None)
288 date_fin = "31-12-%s" % request.GET.get('annee', None)
289
290 implantation = request.GET.get('implantation')
291 region = request.GET.get('region')
292
293 custom_filter = {}
294 if implantation:
295 custom_filter['dossier__poste__implantation'] = implantation
296 if region:
297 custom_filter['dossier__poste__implantation__region'] = region
298
299 c = {
300 'title': 'Rapport de masse salariale',
301 'form': form,
302 'headers': [],
303 'query_string': query_string,
304 }
305 if date_debut or date_fin:
306 masse = MasseSalariale(date_debut, date_fin, custom_filter,
307 request.GET.get('ne_pas_grouper', False))
308 if masse.rapport:
309 if request.GET.get('ods'):
310 for h in (
311 h for h in masse.headers if 'background-color' in h[2]
312 ):
313 del h[2]['background-color']
314 masse.ods()
315 output = StringIO.StringIO()
316 masse.doc.save(output)
317 output.seek(0)
318
319 response = HttpResponse(
320 FileWrapper(output),
321 content_type=(
322 'application/vnd.oasis.opendocument.spreadsheet'
323 )
324 )
325 response['Content-Disposition'] = \
326 'attachment; filename=Masse Salariale %s.ods' % \
327 masse.annee
328 return response
329 else:
330 c['rapport'] = masse.rapport
331 c['header_keys'] = [h[0] for h in masse.headers]
332 #on enleve le background pour le header
333 for h in (
334 h for h in masse.headers if 'background-color' in h[2]
335 ):
336 h[2]['background'] = 'none'
337 h = SortHeaders(request, masse.headers, order_field_type="ot",
338 not_sortable=c['header_keys'], order_field="o")
339 c['headers'] = list(h.headers())
340 for key, nom, opts in masse.headers:
341 c['headers']
342 c['total'] = masse.grand_totaux[0]
343 c['total_euro'] = masse.grand_totaux[1]
344 c['colspan'] = len(c['header_keys']) - 1
345 get_filtre.append(('ods', True))
346 query_string = urllib.urlencode(get_filtre)
347 c['url_ods'] = "%s?%s" % (
348 reverse('rhr_masse_salariale'), query_string)
349
350 return render_to_response(
351 'rh/rapports/masse_salariale.html', c, RequestContext(request)
352 )
353
354
355 @login_required
356 @drh_or_admin_required
357 def rapports_remuneration(request):
358
359 lookup_params = dict(request.GET.items())
360 if 'ot' in lookup_params:
361 del lookup_params['ot']
362 if 'o' in lookup_params:
363 del lookup_params['o']
364
365 for key, value in lookup_params.items():
366 if not isinstance(key, str):
367 # 'key' will be used as a keyword argument later, so Python
368 # requires it to be a string.
369 del lookup_params[key]
370 lookup_params[smart_str(key)] = value
371
372 employes = rh.Employe.objects.all()
373 if 'o' in request.GET:
374 employes = employes.order_by(
375 ('-' if request.GET.get('ot') == "desc" else '') + request.GET['o']
376 )
377
378 employes = employes.filter(**lookup_params)
379
380 output = []
381 headers = [
382 ("id", u"# de l'employé"),
383 ("nom", u"Nom"),
384 ("prenom", u"Prénom"),
385 ("", u"Salaire"),
386 ("", u"RAS"),
387 ("", u"Indemnités"),
388 ("", u"Accessoire"),
389 ("", u"Charges patronales"),
390 ("", u"Total"),
391 ]
392 h = SortHeaders(request, headers, order_field_type="ot", order_field="o")
393
394 for employe in employes:
395 line = {}
396 output.append(line)
397
398 dossiers = employe.rh_dossiers.all()
399
400 remun = {}
401 remun_sum_euro = 0
402
403 for dossier in dossiers:
404 this_remun, this_remun_sum, this_remun_sum_euro = \
405 calc_remun(dossier)
406
407 for item in this_remun:
408 if item not in remun:
409 remun[item] = this_remun[item]
410 else:
411 remun[item][0] += this_remun[item][0]
412 remun[item][1] += this_remun[item][1]
413
414 remun_sum_euro += this_remun_sum_euro
415
416 line['remun_sum_euro'] = remun_sum_euro
417
418 for r in remun:
419 if r == u'Indemnité':
420 line['Indemnite'] = remun[r][1]
421 else:
422 line[r] = remun[r][1]
423
424 line['id'] = employe.id
425 line['nom'] = employe.nom
426 line['prenom'] = employe.prenom
427
428 c = {
429 'title': 'Rapport de remuneration',
430 'employes': output,
431 'headers': list(h.headers()),
432 }
433
434 return render_to_response(
435 'rh/rapports/remuneration.html', c, RequestContext(request)
436 )
437
438
439 @login_required
440 @drh_or_admin_required
441 def rapports_employe_sans_contrat(request):
442
443 lookup_params = dict(request.GET.items())
444 if 'ot' in lookup_params:
445 del lookup_params['ot']
446 if 'o' in lookup_params:
447 del lookup_params['o']
448
449 for key, value in lookup_params.items():
450 if not isinstance(key, str):
451 # 'key' will be used as a keyword argument later, so Python
452 # requires it to be a string.
453 del lookup_params[key]
454 lookup_params[smart_str(key)] = value
455
456 employes_query = rh.Employe.objects
457 if 'o' in request.GET:
458 employes_query = employes_query.order_by(
459 ('-' if request.GET.get('ot') == "desc" else '') + request.GET['o']
460 )
461
462 employes = {}
463
464 dossiers_en_cours = rh.Dossier.objects.filter(
465 Q(date_fin=None) | Q(date_fin__gt=date.today())
466 )
467 tous_contrats_echus = rh.Contrat.objects.filter(
468 date_fin__lt=date.today(), dossier__in=dossiers_en_cours
469 )
470 contrats = tous_contrats_echus.filter(**lookup_params).all()
471 for c in contrats:
472 if c.dossier.employe.id not in employes.keys():
473 employes[c.dossier.employe.id] = {
474 'employe': c.dossier.employe,
475 'dossiers': []
476 }
477 employes[c.dossier.employe.id]['dossiers'] += [c.dossier]
478
479 headers = [
480 ("id", u"# de l'employé"),
481 ("nom", u"Nom"),
482 ("prenom", u"Prénom"),
483 ("dossier", u"Dossiers"),
484 ]
485 h = SortHeaders(
486 request, headers, order_field_type="ot", order_field="o",
487 not_sortable=('dossier',)
488 )
489
490 c = {
491 'title': u'Rapport des employés sans contrat',
492 'employes': employes,
493 'count': len(employes),
494 'headers': list(h.headers()),
495 }
496
497 return render_to_response(
498 'rh/rapports/employes_sans_contrat.html', c, RequestContext(request)
499 )
500
501
502 @login_required
503 @drh_or_admin_required
504 def rapports_postes_modelisation(request):
505 c = {}
506 data = []
507
508 for categorie in rh.CategorieEmploi.objects.all():
509 types = rh.TypePoste.objects.filter(categorie_emploi=categorie)
510 data_types = []
511 for t in types.all():
512 postes = rh.Poste.objects.filter(type_poste=t)
513 data_types.append({
514 'num_postes': postes.count(),
515 'postes': postes.all(),
516 'type': categorie,
517 })
518
519 data.append({
520 'categorie': categorie,
521 'nb_types': types.count(),
522 'types': data_types
523 })
524
525 c['data'] = data
526
527 return render_to_response(
528 'rh/rapports/postes_modelisation.html', c, RequestContext(request)
529 )
530
531
532 @login_required
533 @drh_or_admin_required
534 def rapports_postes_implantation(request):
535 c = {}
536 data = []
537 for r in ref.Region.objects.all():
538 implantations = []
539 for i in ref.Implantation.objects.filter(region=r):
540 implantations.append({
541 'implantation': i,
542 'postes': rh.Poste.objects.filter(implantation=i),
543 'num_postes': rh.Poste.objects.filter(implantation=i).count(),
544 })
545 data.append({
546 'region': r,
547 'implantations': implantations
548 })
549
550 c['data'] = data
551
552 return render_to_response(
553 'rh/rapports/postes_implantation.html', c, RequestContext(request)
554 )
555
556
557 @login_required
558 @drh_or_admin_required
559 def rapports_postes_service(request):
560 c = {}
561 data = []
562 for s in rh.Service.objects.all():
563 postes = rh.Poste.objects.filter(service=s).all()
564 num_postes = rh.Poste.objects.filter(service=s).count()
565 data.append({'service': s, 'num_postes': num_postes, 'postes': postes})
566
567 c['data'] = data
568 return render_to_response(
569 'rh/rapports/postes_service.html', c, RequestContext(request)
570 )
571
572
573 def region_protected(model):
574 def wrapper(func):
575 def wrapped(request, id):
576 if request.user.is_superuser:
577 return func(request, id)
578 user_groups = request.user.groups.all()
579 if grp_drh in user_groups:
580 return func(request, id)
581 if grp_correspondants_rh in user_groups:
582 employe = get_employe_from_user(request.user)
583 q = Q(**{
584 model.prefix_implantation: employe.implantation.region
585 })
586 qs = model.objects.filter(q)
587 if int(id) in [o.id for o in qs]:
588 return func(request, id)
589 return redirect_interdiction(request)
590 return wrapped
591 return wrapper
592
593
594 @region_protected(rh.Dossier)
595 def dossier_apercu(request, dossier_id):
596 d = get_object_or_404(rh.Dossier, pk=dossier_id)
597 c = {
598 'title': u"Dossier %s" % (d, ),
599 'is_popup': request.GET.get('_popup', False),
600 'dossier': d,
601 'pieces': rh.DossierPiece.objects.filter(dossier__exact=d),
602 'contrats': rh.Contrat.objects.filter(dossier__exact=d),
603 'commentaires': rh.DossierCommentaire.objects.filter(dossier=d).all(),
604 'media_url': settings.PRIVE_MEDIA_URL,
605 }
606 return render_to_response(
607 'admin/rh/dossier/apercu.html', c, RequestContext(request)
608 )
609
610
611 @region_protected(rh.Poste)
612 def poste_apercu(request, poste_id):
613 p = get_object_or_404(rh.Poste, pk=poste_id)
614 c = {
615 'title': u"Poste %s" % (p, ),
616 'is_popup': request.GET.get('_popup', False),
617 'poste': p,
618 'financements': (
619 rh.PosteFinancement.objects.filter(poste=poste_id).all()
620 ),
621 'pieces': rh.PostePiece.objects.filter(poste=poste_id).all(),
622 'dossiers': (
623 rh.Dossier.objects.filter(poste=poste_id)
624 .order_by("-date_debut").all()
625 ),
626 'comparaisons': (
627 rh.PosteComparaison.objects.filter(poste=poste_id).all()
628 ),
629 'commentaires': (
630 rh.PosteCommentaire.objects.filter(poste=poste_id).all()
631 ),
632 'media_url': settings.PRIVE_MEDIA_URL,
633 }
634 return render_to_response(
635 'admin/rh/poste/apercu.html', c, RequestContext(request)
636 )
637
638
639 def employe_apercu(request, employe_id):
640 employe = get_object_or_404(rh.Employe, pk=employe_id)
641 user_groups = request.user.groups.all()
642 dossiers = None
643
644 if request.user.is_superuser or \
645 grp_drh in user_groups:
646 q = Q(employe=employe)
647 if grp_correspondants_rh in user_groups:
648 regions = [
649 d.poste.implantation.region for d in employe.rh_dossiers.all()
650 ]
651 q = Q(employe=employe) & Q(implantation__region__in=regions)
652
653 dossiers = rh.Dossier.objects.filter(q).order_by('-date_debut')
654
655 c = {
656 'title': u"Employe %s" % (employe, ),
657 'is_popup': request.GET.get('_popup', False),
658 'employe': employe,
659 'dossiers': dossiers,
660 'media_url': settings.PRIVE_MEDIA_URL,
661 }
662 return render_to_response(
663 'admin/rh/employe/apercu.html', c, RequestContext(request)
664 )
665
666
667 @login_required
668 @drh_or_admin_required
669 def organigrammes_employe(request, id, level="all"):
670
671 poste = get_object_or_404(rh.Poste, pk=id)
672 dossiers_by_poste = dict(
673 (d.poste_id, d)
674 for d in rh.Dossier.objects.select_related('employe', 'poste').all()
675 )
676 postes_by_id = dict((p.id, p) for p in rh.Poste.objects.all())
677
678 e = dossiers_by_poste[poste.id].employe
679 name = u"Organigramme de [%s] %s %s" % (e.id, e.nom.upper(), e.prenom)
680 graph = pgv.AGraph()
681
682 if rh.Poste.objects.filter(responsable=poste).count() > 0:
683 postes_handle = [poste]
684 while postes_handle:
685 postes_handle = rh.Poste.objects.select_related('implantation') \
686 .filter(
687 Q(date_fin__gt=date.today()) | Q(date_fin=None),
688 Q(date_debut__lt=date.today()) | Q(date_debut=None),
689 responsable__in=postes_handle
690 ).exclude(supprime=True).exclude(responsable=None).all()
691
692 for p in postes_handle:
693 if p.responsable_id != p.id:
694 graph.add_edge(
695 dossiers_by_poste[p.responsable_id].poste_id, p.id
696 )
697
698 else:
699 graph.add_node(poste.id)
700
701 if level != "all":
702 postes_niveau = [poste.id]
703 for niveau in range(int(level)):
704 postes_niveau = [
705 p.id for p in
706 rh.Poste.objects.filter(responsable__in=postes_niveau).all()
707 ]
708
709 while postes_niveau:
710 postes_niveau = [
711 p.id for p in
712 rh.Poste.objects.filter(responsable__in=postes_niveau).all()
713 ]
714 if postes_niveau:
715 for p in postes_niveau:
716 if graph.has_node(p):
717 graph.delete_node(p)
718
719 a = graph
720 a.name = name.encode('ascii', 'xmlcharrefreplace')
721
722 poste_remontant = poste
723 while poste_remontant.responsable_id:
724 a.add_edge(poste_remontant.responsable_id, poste_remontant.id)
725 poste_remontant = poste_remontant.responsable
726
727 rh_graph.bind_poste_to_graph(a, postes_by_id)
728 #a.graph_attr['normalize'] = True
729 #a.graph_attr['level'] = 2
730 a.layout(prog='dot')
731
732 svg = a.draw(format='svg')
733
734 c = {
735 'svg': svg
736 }
737
738 if 'forcer' in request.GET:
739 response = HttpResponse(svg, mimetype='image/svg+xml')
740 response['Content-Disposition'] = \
741 'attachment; filename=organigramme.svg'
742 return response
743
744 return render_to_response(
745 'rh/organigrammes/employe.html', c, RequestContext(request),
746 mimetype="image/svg+xml"
747 )
748
749
750 @login_required
751 @drh_or_admin_required
752 def organigrammes_service(request, id):
753
754 service = get_object_or_404(rh.Service, pk=id)
755 svg = rh_graph.organigramme_postes_cluster( \
756 cluster_filter={"service": service}, \
757 titre=u"Organigramme du service %s" % service.nom,
758 cluster_titre=service.nom)
759
760 c = {
761 'svg': svg
762 }
763
764 return render_to_response(
765 'rh/organigrammes/vide.html', c, RequestContext(request),
766 mimetype="image/svg+xml"
767 )
768
769
770 @login_required
771 @drh_or_admin_required
772 def organigrammes_implantation(request, id):
773
774 implantation = get_object_or_404(ref.Implantation, pk=id)
775 svg = rh_graph.organigramme_postes_cluster( \
776 cluster_filter={"implantation": implantation}, \
777 titre=u"Organigramme de l'implantation %s" % implantation.nom,
778 cluster_titre=implantation.nom)
779
780 c = {
781 'svg': svg
782 }
783
784 return render_to_response(
785 'rh/organigrammes/vide.html', c, RequestContext(request),
786 mimetype="image/svg+xml"
787 )
788
789
790 @login_required
791 @drh_or_admin_required
792 def organigrammes_region(request, id):
793
794 region = get_object_or_404(ref.Region, pk=id)
795 svg = rh_graph.organigramme_postes_cluster( \
796 cluster_filter={"implantation__region": region}, \
797 titre=u"Organigramme du bureau de %s" % region.nom,
798 cluster_titre=region.nom)
799
800 c = {
801 'svg': svg
802 }
803
804 return render_to_response(
805 'rh/organigrammes/vide.html', c, RequestContext(request),
806 mimetype="image/svg+xml"
807 )