Masse salariale HTML
[auf_rh_dae.git] / project / rh / views.py
CommitLineData
e9bbd6ba 1# -*- encoding: utf-8 -*-
22343fe7 2
c9122f1d 3from datetime import date
a7de62d7 4from itertools import izip
9b0a8554 5
9f55f18a
JPC
6import pygraphviz as pgv
7
dcd1b959 8from django.core.urlresolvers import reverse
fbe60a9d 9from django.db.models import Q
3411ac33 10from django.contrib.auth.decorators import login_required
fd009814 11from django.utils.encoding import smart_str
22343fe7 12from django.shortcuts import render_to_response, get_object_or_404
e9bbd6ba 13from django.template import RequestContext
a251ac8d 14from django.http import HttpResponse
e9bbd6ba 15
d04d084c 16from datamaster_modeles import models as ref
ae936f8d 17
d04d084c 18from rh import models as rh
e2c0b1ac 19from rh.lib import calc_remun
02c1b3dc 20from rh.decorators import drh_or_admin_required
9d53bc73 21from rh.templatetags.rapports import SortHeaders
f0f6b03e 22from rh.change_list import RechercheTemporelle
5c0f1778 23from rh import graph as rh_graph
df37184c 24from rh.masse_salariale import MasseSalariale
a9faef67 25
9817fed5
OL
26# pas de reference a DAE devrait etre refactorisé
27from dae.utils import get_employe_from_user
28from dae.decorators import redirect_interdiction
29from dae.workflow import grp_drh, grp_correspondants_rh
baf9b78c 30from django.conf import settings
9817fed5 31
22343fe7 32
c9122f1d 33@login_required
34def profil(request):
35 """Profil personnel de l'employé - éditable"""
36 rc = RequestContext(request)
37 c = {}
22343fe7 38
c9122f1d 39 employe = rc['this_employe']
22343fe7 40
c9122f1d 41 c['user'] = request.user
42 c['employe'] = employe
c9122f1d 43 return render_to_response('rh/profil.html', c, rc)
22343fe7
OL
44
45
3411ac33 46@login_required
a9faef67 47def employes_liste(request):
48 """Liste des employés."""
5ea6b5bb 49 today = date.today()
50 employes = rh.Employe.objects \
5ea6b5bb 51 .exclude(dossiers__date_debut__gt=today) \
52 .exclude(dossiers__date_fin__lt=today) \
53 .order_by('nom')
a9faef67 54 c = {
22343fe7
OL
55 'user': request.user,
56 'employes': employes,
a9faef67 57 }
22343fe7
OL
58 return render_to_response('rh/employes_liste.html',
59 c,
60 RequestContext(request))
61
62
3411ac33 63@login_required
a9faef67 64def employe(request, id):
65 """Information publique sur un employé."""
66 try:
67 employe = rh.Employe.objects.get(pk=id)
68 except:
69 employe = rh.Employe.objects.none()
70 c = {
22343fe7
OL
71 'user': request.user,
72 'employe': employe,
a9faef67 73 }
74 return render_to_response('rh/employe.html', c, RequestContext(request))
63e17dff
PP
75
76
08faf06e
JPC
77@login_required
78@drh_or_admin_required
63e17dff
PP
79def rapports_poste(request):
80
fd009814
PP
81 lookup_params = dict(request.GET.items())
82
83 for key, value in lookup_params.items():
9d53bc73
JPC
84 if key == 'o' or key == 'ot':
85 del lookup_params[key]
86 continue
fd009814
PP
87 if not isinstance(key, str):
88 # 'key' will be used as a keyword argument later, so Python
89 # requires it to be a string.
90 del lookup_params[key]
91 lookup_params[smart_str(key)] = value
92
7821915f 93 if key == 'comble':
7821915f
PP
94 del lookup_params[key]
95
ed3cbb32
OL
96 postes = rh.Poste.objects.select_related('implantation') \
97 .extra(select={'employe_id':'select group_concat(employe separator "|") from rh_dossier where poste=rh_poste.id and rh_dossier.date_fin is null %s' % \
9202c5db
JPC
98 ("%s" % (('order by employe %s' % ('asc' if 'ot' in request.GET and request.GET['ot'] == "asc" else "desc"))) if 'o' in request.GET and request.GET['o'] == "employe_id" else "") \
99 }) \
ed3cbb32 100 .extra(select={'employe_nom':'select group_concat(rh_employe.nom separator "|") from rh_dossier inner join rh_employe on rh_dossier.employe = rh_employe.id where poste=rh_poste.id and rh_dossier.date_fin is null %s' % \
9202c5db
JPC
101 ("%s" % (('order by rh_employe.nom %s' % ('asc' if 'ot' in request.GET and request.GET['ot'] == "asc" else "desc"))) if 'o' in request.GET and request.GET['o'] == "employe_nom" else "") \
102 }) \
ed3cbb32 103 .extra(select={'employe_prenom':'select group_concat(rh_employe.prenom separator "|") from rh_dossier inner join rh_employe on rh_dossier.employe = rh_employe.id where poste=rh_poste.id and rh_dossier.date_fin is null %s' % \
9202c5db
JPC
104 ("%s" % (('order by rh_employe.prenom %s' % ('asc' if 'ot' in request.GET and request.GET['ot'] == "asc" else "desc"))) if 'o' in request.GET and request.GET['o'] == "employe_prenom" else "") \
105 })
9d53bc73 106
65e02621 107 postes = postes.filter(**lookup_params)
9d53bc73 108 if 'o' in request.GET:
65e02621
JPC
109 postes = postes.order_by("%s%s" % ('-' if 'ot' in request.GET and request.GET['ot'] == "desc" else '', request.GET['o']))
110
a7de62d7
JPC
111 out = []
112 for p in postes:
113 out.append({
114 'id': p.id,
115 'nom': p.nom,
116 'implantation': p.implantation,
117 'employes': [] if not p.employe_id else [{'id': id, 'nom': nom, 'prenom': prenom} for id, nom, prenom in izip(p.employe_id.split('|'), p.employe_nom.split('|'), p.employe_prenom.split('|'))] })
118
119
4dade240
JPC
120 headers = [
121 ("id", u"# du poste"),
122 ("nom", u"Nom du poste"),
65e02621 123 ("implantation__id", u"Implantation"),
4dade240 124 ("employe_nom", u"Nom"),
4dade240
JPC
125 ]
126 h = SortHeaders(request, headers, order_field_type="ot", order_field="o")
63e17dff
PP
127 c = {
128 'title': 'Rapport des postes',
a7de62d7
JPC
129 'postes': out,
130 'count': len(out),
65e02621 131 'headers': list(h.headers()),
63e17dff
PP
132 }
133
134 return render_to_response('rh/rapports/postes.html', c, RequestContext(request))
f2d65e83 135
02c1b3dc
JPC
136@login_required
137@drh_or_admin_required
f2d65e83 138def rapports_contrat(request):
dcd1b959
OL
139 if 'HTTP_REFERER' in request.META.keys():
140 referer = request.META['HTTP_REFERER']
141 referer = "/".join(referer.split('/')[3:])
142 referer = "/%s" % referer.split('?')[0]
143 if referer != reverse('rhr_contrats'):
144 params = request.GET.copy()
145 params.update({'statut': 'Actif'})
146 request.GET = params
f2d65e83
PP
147
148 lookup_params = dict(request.GET.items())
65e02621
JPC
149 if 'ot' in lookup_params:
150 del lookup_params['ot']
151 if 'o' in lookup_params:
152 del lookup_params['o']
f2d65e83
PP
153
154 for key, value in lookup_params.items():
155 if not isinstance(key, str):
156 # 'key' will be used as a keyword argument later, so Python
157 # requires it to be a string.
158 del lookup_params[key]
159 lookup_params[smart_str(key)] = value
160
65e02621 161 contrats = rh.Contrat.objects.select_related('dossier', 'dossier__poste', 'dossier__poste__implantation', 'type_contrat', 'dossier__employe')
22343fe7 162
6bee05ff 163 cl = RechercheTemporelle(dict(request.GET.items()), rh.Contrat)
f0f6b03e 164 lookup_params = cl.purge_params(lookup_params)
dcd1b959
OL
165 q_temporel = cl.get_q_temporel(contrats)
166 q = Q(**lookup_params) & q_temporel
167 contrats = contrats.filter(q).exclude(dossier__employe__supprime=1)
f0f6b03e 168
65e02621
JPC
169 if 'o' in request.GET:
170 contrats = contrats.order_by("%s%s" % ('-' if 'ot' in request.GET and request.GET['ot'] == "desc" else '', request.GET['o']))
f2d65e83 171
8ee135b7
JPC
172 employes = set([c.dossier.employe_id for c in contrats])
173
65e02621
JPC
174 headers = [
175 ("dossier__employe__id", u"# de l'employé"),
176 ("dossier__employe__nom", u"Nom"),
177 ("dossier__employe__prenom", u"Prénom"),
178 ("type_contrat__nom", u"Poste"),
179 ("type_contrat__nom", u"Type de contrat"),
180 ("date_debut", u"Date début"),
181 ("date_fin", u"Date fin"),
182 ]
183 h = SortHeaders(request, headers, order_field_type="ot", order_field="o")
184
f2d65e83 185 c = {
f0f6b03e 186 'cl' : cl,
f2d65e83
PP
187 'title': 'Rapport des contrats',
188 'contrats': contrats,
8ee135b7
JPC
189 'count': len(contrats),
190 'count_employe' : len(employes),
65e02621 191 'headers': list(h.headers()),
f2d65e83
PP
192 }
193
194 return render_to_response('rh/rapports/contrats.html', c, RequestContext(request))
e2c0b1ac
PP
195
196
02c1b3dc
JPC
197@login_required
198@drh_or_admin_required
98d6eb6c 199def rapports_masse_salariale(request):
df37184c
JPC
200
201 date_debut = request.GET.get("date_debut", None)
202 date_fin = request.GET.get("date_fin", None)
203
204 implantation = request.GET.get('dossier__poste__implantation')
205 region = request.GET.get('dossier__poste__implantation__region')
206
207 custom_filter = {}
208 if implantation:
209 custom_filter['dossier__poste__implantation'] = implantation
210 if region:
211 custom_filter['dossier__poste__implantation__region'] = region
212
df37184c
JPC
213 c = {
214 'headers': [],
df37184c 215 }
22b53270
JPC
216 if date_debut or date_fin:
217 masse = MasseSalariale(date_debut, date_fin, custom_filter)
515b83c3
JPC
218 if masse.rapport:
219 c['rapport'] = masse.rapport
57e2b793
JPC
220 headers = masse.headers
221 c['header_keys'] = [h[0] for h in masse.headers]
515b83c3
JPC
222 h = SortHeaders(request, headers, order_field_type="ot", order_field="o")
223 c['headers'] = list(h.headers())
22b53270 224
df37184c 225 return render_to_response('rh/rapports/masse_salariale.html', c, RequestContext(request))
98d6eb6c
JPC
226
227
228@login_required
229@drh_or_admin_required
e2c0b1ac
PP
230def rapports_remuneration(request):
231
232 lookup_params = dict(request.GET.items())
9202c5db
JPC
233 if 'ot' in lookup_params:
234 del lookup_params['ot']
235 if 'o' in lookup_params:
236 del lookup_params['o']
e2c0b1ac
PP
237
238 for key, value in lookup_params.items():
239 if not isinstance(key, str):
240 # 'key' will be used as a keyword argument later, so Python
241 # requires it to be a string.
242 del lookup_params[key]
243 lookup_params[smart_str(key)] = value
244
245 employes = rh.Employe.objects.all()
9202c5db
JPC
246 if 'o' in request.GET:
247 employes = employes.order_by("%s%s" % ('-' if 'ot' in request.GET and request.GET['ot'] == "desc" else '', request.GET['o']))
248
e2c0b1ac
PP
249 employes = employes.filter(**lookup_params)
250
251 output = []
9202c5db
JPC
252 headers = [
253 ("id", u"# de l'employé"),
254 ("nom", u"Nom"),
255 ("prenom", u"Prénom"),
256 ("", u"Salaire"),
257 ("", u"RAS"),
258 ("", u"Indemnités"),
259 ("", u"Accessoire"),
260 ("", u"Charges patronales"),
261 ("", u"Total"),
262 ]
263 h = SortHeaders(request, headers, order_field_type="ot", order_field="o")
e2c0b1ac
PP
264
265 for employe in employes:
266 line = {}
267 output.append(line)
268
da6c523f 269 dossiers = employe.rh_dossiers.all()
e2c0b1ac
PP
270
271 remun = {}
272 remun_sum_euro = 0
273
274 for dossier in dossiers:
275 this_remun, this_remun_sum, this_remun_sum_euro = calc_remun(dossier)
276
277 for item in this_remun:
278 if item not in remun:
279 remun[item] = this_remun[item]
280 else:
281 remun[item][0] += this_remun[item][0]
282 remun[item][1] += this_remun[item][1]
283
284 remun_sum_euro += this_remun_sum_euro
285
286 line['remun_sum_euro'] = remun_sum_euro
287
288 for r in remun:
289 if r == u'Indemnité':
e2c0b1ac
PP
290 line['Indemnite'] = remun[r][1]
291 else:
292 line[r] = remun[r][1]
293
294 line['id'] = employe.id
295 line['nom'] = employe.nom
296 line['prenom'] = employe.prenom
297
298
299 c = {
300 'title': 'Rapport de remuneration',
301 'employes': output,
9202c5db 302 'headers': list(h.headers()),
e2c0b1ac
PP
303 }
304
305 return render_to_response('rh/rapports/remuneration.html', c, RequestContext(request))
3ebc0952 306
783e077a
JPC
307@login_required
308@drh_or_admin_required
c8b22fd1
JPC
309def rapports_employe_sans_contrat(request):
310
311 lookup_params = dict(request.GET.items())
312 if 'ot' in lookup_params:
313 del lookup_params['ot']
314 if 'o' in lookup_params:
315 del lookup_params['o']
316
317 for key, value in lookup_params.items():
318 if not isinstance(key, str):
319 # 'key' will be used as a keyword argument later, so Python
320 # requires it to be a string.
321 del lookup_params[key]
322 lookup_params[smart_str(key)] = value
323
324 employes_query = rh.Employe.objects
325 if 'o' in request.GET:
326 employes_query = employes_query.order_by("%s%s" % ('-' if 'ot' in request.GET and request.GET['ot'] == "desc" else '', request.GET['o']))
327
7c5645f0 328 employes = {}
22343fe7 329
00c9d7c2
OL
330 dossiers_en_cours = rh.Dossier.objects.filter(Q(date_fin=None) | Q(date_fin__gt=date.today()))
331 tous_contrats_echus = rh.Contrat.objects.filter(date_fin__lt=date.today(), dossier__in=dossiers_en_cours)
332 contrats = tous_contrats_echus.filter(**lookup_params).all()
333 for c in contrats:
334 if c.dossier.employe.id not in employes.keys():
335 employes[c.dossier.employe.id] = {'employe': c.dossier.employe, 'dossiers': []}
336 employes[c.dossier.employe.id]['dossiers'] += [c.dossier,]
22343fe7 337
00c9d7c2 338
c8b22fd1
JPC
339
340 headers = [
1d2d4dc2
JPC
341 ("id", u"# de l'employé"),
342 ("nom", u"Nom"),
343 ("prenom", u"Prénom"),
80518280 344 ("dossier", u"Dossiers"),
c8b22fd1 345 ]
80518280 346 h = SortHeaders(request, headers, order_field_type="ot", order_field="o", not_sortable=('dossier',))
c8b22fd1
JPC
347
348 c = {
349 'title': u'Rapport des employés sans contrat',
350 'employes': employes,
351 'count': len(employes),
352 'headers': list(h.headers()),
353 }
354
355 return render_to_response('rh/rapports/employes_sans_contrat.html', c, RequestContext(request))
356
357@login_required
358@drh_or_admin_required
857b5c24
JPC
359def rapports_postes_modelisation(request):
360 c = {}
361 data = []
3c1ba807
JPC
362
363 for f in rh.FamilleEmploi.objects.all():
364 types = rh.TypePoste.objects.filter(famille_emploi=f)
365 data_types = []
366 for t in types.all():
367 postes = rh.Poste.objects.filter(type_poste=t)
368 data_types.append({
369 'num_postes': postes.count(),
370 'postes': postes.all(),
371 'type': f,
857b5c24 372 })
3c1ba807 373
857b5c24 374 data.append({
3c1ba807
JPC
375 'famille': f,
376 'nb_types': types.count(),
377 'types' : data_types
857b5c24
JPC
378 })
379
380 c['data'] = data
381
382
383 return render_to_response('rh/rapports/postes_modelisation.html', c, RequestContext(request))
384
385
386@login_required
387@drh_or_admin_required
783e077a
JPC
388def rapports_postes_implantation(request):
389 c = {}
390 data = []
391 for r in ref.Region.objects.all():
392 implantations = []
393 for i in ref.Implantation.objects.filter(region=r):
394 implantations.append({
395 'implantation': i,
396 'postes': rh.Poste.objects.filter(implantation=i),
397 'num_postes': rh.Poste.objects.filter(implantation=i).count(),
398 })
399 data.append({
400 'region': r,
401 'implantations': implantations
402 })
403
404 c['data'] = data
405
406
407 return render_to_response('rh/rapports/postes_implantation.html', c, RequestContext(request))
408
409
410@login_required
411@drh_or_admin_required
412def rapports_postes_service(request):
413 c = {}
9988aafb
JPC
414 data = []
415 for s in rh.Service.objects.all():
416 postes = rh.Poste.objects.filter(service=s).all()
417 num_postes = rh.Poste.objects.filter(service=s).count()
22343fe7 418 data.append({'service': s, 'num_postes': num_postes, 'postes': postes})
783e077a 419
9988aafb
JPC
420 c['data'] = data
421 return render_to_response('rh/rapports/postes_service.html', c, RequestContext(request))
783e077a
JPC
422
423
32373f2e
OL
424def region_protected(model):
425 def wrapper(func):
426 def wrapped(request, id):
32373f2e
OL
427 if request.user.is_superuser:
428 return func(request, id)
429 user_groups = request.user.groups.all()
430 if grp_drh in user_groups:
431 return func(request, id)
432 if grp_correspondants_rh in user_groups:
433 employe = get_employe_from_user(request.user)
434 q = Q(**{model.prefix_implantation: employe.implantation.region})
435 qs = model.objects.filter(q)
718abc4d 436 if int(id) in [o.id for o in qs]:
32373f2e
OL
437 return func(request, id)
438 return redirect_interdiction(request)
439 return wrapped
440 return wrapper
441
442
443@region_protected(rh.Dossier)
3ebc0952 444def dossier_apercu(request, dossier_id):
baf9b78c 445 d = get_object_or_404(rh.Dossier, pk=dossier_id)
3ebc0952
OL
446 c = {
447 'is_popup' : request.GET.get('_popup', False),
baf9b78c 448 'dossier' : d,
520ab455
JPC
449 'pieces' : rh.DossierPiece.objects.filter(dossier__exact=d),
450 'contrats' : rh.Contrat.objects.filter(dossier__exact=d),
2a36598b 451 'commentaires' : rh.DossierCommentaire.objects.filter(dossier__exact=d).all(),
abf91905 452 'media_url': settings.PRIVE_MEDIA_URL,
3ebc0952
OL
453 }
454 return render_to_response('admin/rh/dossier/apercu.html', c, RequestContext(request))
4a1f2ece 455
fbe60a9d
OL
456@region_protected(rh.Poste)
457def poste_apercu(request, poste_id):
458 c = {
459 'is_popup' : request.GET.get('_popup', False),
0dcfc806
JPC
460 'poste' : get_object_or_404(rh.Poste, pk=poste_id),
461 'financements' : rh.PosteFinancement.objects.filter(poste=poste_id).all(),
462 'pieces' : rh.PostePiece.objects.filter(poste=poste_id).all(),
463 'dossiers' : rh.Dossier.objects.filter(poste=poste_id).order_by("-date_debut").all(),
464 'comparaisons' : rh.PosteComparaison.objects.filter(poste=poste_id).all(),
465 'commentaires' : rh.PosteCommentaire.objects.filter(poste=poste_id).all(),
abf91905 466 'media_url': settings.PRIVE_MEDIA_URL,
fbe60a9d
OL
467 }
468 return render_to_response('admin/rh/poste/apercu.html', c, RequestContext(request))
469
4a1f2ece
OL
470def employe_apercu(request, employe_id):
471 employe = get_object_or_404(rh.Employe, pk=employe_id)
fbe60a9d 472 user_groups = request.user.groups.all()
fbe60a9d
OL
473 dossiers = None
474
475 if request.user.is_superuser or \
476 grp_drh in user_groups:
477 q = Q(employe=employe)
478 if grp_correspondants_rh in user_groups:
7eeafa57 479 regions = [d.poste.implantation.region for d in employe.rh_dossiers.all()]
fbe60a9d 480 q = Q(employe=employe) & Q(implantation__region__in=regions)
22343fe7
OL
481
482 dossiers = rh.Dossier.objects.filter(q).order_by('-date_debut')
483
4a1f2ece
OL
484 c = {
485 'is_popup' : request.GET.get('_popup', False),
486 'employe' : employe,
fbe60a9d 487 'dossiers' : dossiers,
abf91905 488 'media_url': settings.PRIVE_MEDIA_URL,
4a1f2ece
OL
489 }
490 return render_to_response('admin/rh/employe/apercu.html', c, RequestContext(request))
150d83ec 491
77bd83d1
JPC
492@login_required
493@drh_or_admin_required
56264a85 494def organigrammes_employe(request, id, level="all"):
08faf06e
JPC
495
496 poste = get_object_or_404(rh.Poste, pk=id)
5c0f1778
JPC
497 dossiers_by_poste = dict((d.poste_id, d) for d in rh.Dossier.objects.select_related('employe', 'poste').all())
498 postes_by_id = dict((p.id, p) for p in rh.Poste.objects.all())
499
500 e = dossiers_by_poste[poste.id].employe
501 name = u"Organigramme de [%s] %s %s" % (e.id, e.nom.upper(), e.prenom)
58014aec 502 graph = pgv.AGraph()
5c0f1778 503
f187a10f 504 if rh.Poste.objects.filter(responsable=poste).count() > 0:
58014aec
JPC
505 postes_handle = [poste]
506 while postes_handle:
507 postes_handle = rh.Poste.objects.select_related('implantation').filter((Q(date_fin__gt=date.today()) | Q(date_fin=None)) & (Q(date_debut__lt=date.today()) | Q(date_debut=None)) ).filter(responsable__in=postes_handle).exclude(supprime=True).exclude(responsable=None).all()
32373f2e 508
58014aec
JPC
509 for p in postes_handle:
510 if p.responsable_id != p.id:
511 graph.add_edge(dossiers_by_poste[p.responsable_id].poste_id, p.id)
13ad5ad5 512
f187a10f 513 else:
5c0f1778
JPC
514 graph.add_node(poste.id)
515
4afec2e1
JPC
516 if level != "all":
517 postes_niveau = [poste.id]
518 for niveau in range(int(level)):
519 postes_niveau = [p.id for p in rh.Poste.objects.filter(responsable__in=postes_niveau).all()]
520
521 while postes_niveau:
522 postes_niveau = [p.id for p in rh.Poste.objects.filter(responsable__in=postes_niveau).all()]
523 if postes_niveau:
524 for p in postes_niveau:
525 if graph.has_node(p):
526 graph.remove_node(p)
527
58014aec 528 a = graph
4afec2e1 529 a.name = name.encode('ascii', 'xmlcharrefreplace')
5c0f1778
JPC
530
531 poste_remontant = poste
532 while poste_remontant.responsable_id:
533 a.add_edge(poste_remontant.responsable_id, poste_remontant.id)
534 poste_remontant = poste_remontant.responsable
535
536 rh_graph.bind_poste_to_graph(a, postes_by_id)
537 #a.graph_attr['normalize'] = True
538 #a.graph_attr['level'] = 2
539 a.layout(prog='dot')
540
541 svg = a.draw(format='svg')
542
543 c = {
544 'svg': svg
545 }
a251ac8d
JPC
546
547 if 'forcer' in request.GET:
548 response = HttpResponse(svg, mimetype='image/svg+xml')
549 response['Content-Disposition'] = 'attachment; filename=organigramme.svg'
550 return response
551
c548bef6 552 return render_to_response('rh/organigrammes/employe.html', c, RequestContext(request), mimetype="image/svg+xml")
5c0f1778
JPC
553
554
555@login_required
556@drh_or_admin_required
557def organigrammes_service(request, id):
558
559 service = get_object_or_404(rh.Service, pk=id)
82af5c19
JPC
560 svg = rh_graph.organigramme_postes_cluster( \
561 cluster_filter={"service": service}, \
562 titre=u"Organigramme du service %s" % service.nom,
563 cluster_titre=service.nom)
5c0f1778 564
82af5c19
JPC
565 c = {
566 'svg': svg
567 }
5c0f1778 568
6dec02db 569 return render_to_response('rh/organigrammes/vide.html', c, RequestContext(request), mimetype="image/svg+xml")
5c0f1778 570
82af5c19
JPC
571@login_required
572@drh_or_admin_required
573def organigrammes_implantation(request, id):
5c0f1778 574
82af5c19
JPC
575 implantation = get_object_or_404(ref.Implantation, pk=id)
576 svg = rh_graph.organigramme_postes_cluster( \
577 cluster_filter={"implantation": implantation}, \
578 titre=u"Organigramme de l'implantation %s" % implantation.nom,
579 cluster_titre=implantation.nom)
5c0f1778
JPC
580
581 c = {
582 'svg': svg
583 }
584
6dec02db 585 return render_to_response('rh/organigrammes/vide.html', c, RequestContext(request), mimetype="image/svg+xml")
5c0f1778 586
9da4c195
JPC
587@login_required
588@drh_or_admin_required
589def organigrammes_region(request, id):
590
591 region = get_object_or_404(ref.Region, pk=id)
592 svg = rh_graph.organigramme_postes_cluster( \
593 cluster_filter={"implantation__region": region}, \
594 titre=u"Organigramme du bureau de %s" % region.nom,
595 cluster_titre=region.nom)
596
597 c = {
598 'svg': svg
599 }
600
601 return render_to_response('rh/organigrammes/vide.html', c, RequestContext(request), mimetype="image/svg+xml")