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