Added masse salariale html template
[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
220 headers = [(row[0], row[0]) for row in masse.rapport[0]]
221 h = SortHeaders(request, headers, order_field_type="ot", order_field="o")
222 c['headers'] = list(h.headers())
22b53270 223
df37184c 224 return render_to_response('rh/rapports/masse_salariale.html', c, RequestContext(request))
98d6eb6c
JPC
225
226
227@login_required
228@drh_or_admin_required
e2c0b1ac
PP
229def rapports_remuneration(request):
230
231 lookup_params = dict(request.GET.items())
9202c5db
JPC
232 if 'ot' in lookup_params:
233 del lookup_params['ot']
234 if 'o' in lookup_params:
235 del lookup_params['o']
e2c0b1ac
PP
236
237 for key, value in lookup_params.items():
238 if not isinstance(key, str):
239 # 'key' will be used as a keyword argument later, so Python
240 # requires it to be a string.
241 del lookup_params[key]
242 lookup_params[smart_str(key)] = value
243
244 employes = rh.Employe.objects.all()
9202c5db
JPC
245 if 'o' in request.GET:
246 employes = employes.order_by("%s%s" % ('-' if 'ot' in request.GET and request.GET['ot'] == "desc" else '', request.GET['o']))
247
e2c0b1ac
PP
248 employes = employes.filter(**lookup_params)
249
250 output = []
9202c5db
JPC
251 headers = [
252 ("id", u"# de l'employé"),
253 ("nom", u"Nom"),
254 ("prenom", u"Prénom"),
255 ("", u"Salaire"),
256 ("", u"RAS"),
257 ("", u"Indemnités"),
258 ("", u"Accessoire"),
259 ("", u"Charges patronales"),
260 ("", u"Total"),
261 ]
262 h = SortHeaders(request, headers, order_field_type="ot", order_field="o")
e2c0b1ac
PP
263
264 for employe in employes:
265 line = {}
266 output.append(line)
267
da6c523f 268 dossiers = employe.rh_dossiers.all()
e2c0b1ac
PP
269
270 remun = {}
271 remun_sum_euro = 0
272
273 for dossier in dossiers:
274 this_remun, this_remun_sum, this_remun_sum_euro = calc_remun(dossier)
275
276 for item in this_remun:
277 if item not in remun:
278 remun[item] = this_remun[item]
279 else:
280 remun[item][0] += this_remun[item][0]
281 remun[item][1] += this_remun[item][1]
282
283 remun_sum_euro += this_remun_sum_euro
284
285 line['remun_sum_euro'] = remun_sum_euro
286
287 for r in remun:
288 if r == u'Indemnité':
e2c0b1ac
PP
289 line['Indemnite'] = remun[r][1]
290 else:
291 line[r] = remun[r][1]
292
293 line['id'] = employe.id
294 line['nom'] = employe.nom
295 line['prenom'] = employe.prenom
296
297
298 c = {
299 'title': 'Rapport de remuneration',
300 'employes': output,
9202c5db 301 'headers': list(h.headers()),
e2c0b1ac
PP
302 }
303
304 return render_to_response('rh/rapports/remuneration.html', c, RequestContext(request))
3ebc0952 305
783e077a
JPC
306@login_required
307@drh_or_admin_required
c8b22fd1
JPC
308def rapports_employe_sans_contrat(request):
309
310 lookup_params = dict(request.GET.items())
311 if 'ot' in lookup_params:
312 del lookup_params['ot']
313 if 'o' in lookup_params:
314 del lookup_params['o']
315
316 for key, value in lookup_params.items():
317 if not isinstance(key, str):
318 # 'key' will be used as a keyword argument later, so Python
319 # requires it to be a string.
320 del lookup_params[key]
321 lookup_params[smart_str(key)] = value
322
323 employes_query = rh.Employe.objects
324 if 'o' in request.GET:
325 employes_query = employes_query.order_by("%s%s" % ('-' if 'ot' in request.GET and request.GET['ot'] == "desc" else '', request.GET['o']))
326
7c5645f0 327 employes = {}
22343fe7 328
00c9d7c2
OL
329 dossiers_en_cours = rh.Dossier.objects.filter(Q(date_fin=None) | Q(date_fin__gt=date.today()))
330 tous_contrats_echus = rh.Contrat.objects.filter(date_fin__lt=date.today(), dossier__in=dossiers_en_cours)
331 contrats = tous_contrats_echus.filter(**lookup_params).all()
332 for c in contrats:
333 if c.dossier.employe.id not in employes.keys():
334 employes[c.dossier.employe.id] = {'employe': c.dossier.employe, 'dossiers': []}
335 employes[c.dossier.employe.id]['dossiers'] += [c.dossier,]
22343fe7 336
00c9d7c2 337
c8b22fd1
JPC
338
339 headers = [
1d2d4dc2
JPC
340 ("id", u"# de l'employé"),
341 ("nom", u"Nom"),
342 ("prenom", u"Prénom"),
80518280 343 ("dossier", u"Dossiers"),
c8b22fd1 344 ]
80518280 345 h = SortHeaders(request, headers, order_field_type="ot", order_field="o", not_sortable=('dossier',))
c8b22fd1
JPC
346
347 c = {
348 'title': u'Rapport des employés sans contrat',
349 'employes': employes,
350 'count': len(employes),
351 'headers': list(h.headers()),
352 }
353
354 return render_to_response('rh/rapports/employes_sans_contrat.html', c, RequestContext(request))
355
356@login_required
357@drh_or_admin_required
857b5c24
JPC
358def rapports_postes_modelisation(request):
359 c = {}
360 data = []
3c1ba807
JPC
361
362 for f in rh.FamilleEmploi.objects.all():
363 types = rh.TypePoste.objects.filter(famille_emploi=f)
364 data_types = []
365 for t in types.all():
366 postes = rh.Poste.objects.filter(type_poste=t)
367 data_types.append({
368 'num_postes': postes.count(),
369 'postes': postes.all(),
370 'type': f,
857b5c24 371 })
3c1ba807 372
857b5c24 373 data.append({
3c1ba807
JPC
374 'famille': f,
375 'nb_types': types.count(),
376 'types' : data_types
857b5c24
JPC
377 })
378
379 c['data'] = data
380
381
382 return render_to_response('rh/rapports/postes_modelisation.html', c, RequestContext(request))
383
384
385@login_required
386@drh_or_admin_required
783e077a
JPC
387def rapports_postes_implantation(request):
388 c = {}
389 data = []
390 for r in ref.Region.objects.all():
391 implantations = []
392 for i in ref.Implantation.objects.filter(region=r):
393 implantations.append({
394 'implantation': i,
395 'postes': rh.Poste.objects.filter(implantation=i),
396 'num_postes': rh.Poste.objects.filter(implantation=i).count(),
397 })
398 data.append({
399 'region': r,
400 'implantations': implantations
401 })
402
403 c['data'] = data
404
405
406 return render_to_response('rh/rapports/postes_implantation.html', c, RequestContext(request))
407
408
409@login_required
410@drh_or_admin_required
411def rapports_postes_service(request):
412 c = {}
9988aafb
JPC
413 data = []
414 for s in rh.Service.objects.all():
415 postes = rh.Poste.objects.filter(service=s).all()
416 num_postes = rh.Poste.objects.filter(service=s).count()
22343fe7 417 data.append({'service': s, 'num_postes': num_postes, 'postes': postes})
783e077a 418
9988aafb
JPC
419 c['data'] = data
420 return render_to_response('rh/rapports/postes_service.html', c, RequestContext(request))
783e077a
JPC
421
422
32373f2e
OL
423def region_protected(model):
424 def wrapper(func):
425 def wrapped(request, id):
32373f2e
OL
426 if request.user.is_superuser:
427 return func(request, id)
428 user_groups = request.user.groups.all()
429 if grp_drh in user_groups:
430 return func(request, id)
431 if grp_correspondants_rh in user_groups:
432 employe = get_employe_from_user(request.user)
433 q = Q(**{model.prefix_implantation: employe.implantation.region})
434 qs = model.objects.filter(q)
718abc4d 435 if int(id) in [o.id for o in qs]:
32373f2e
OL
436 return func(request, id)
437 return redirect_interdiction(request)
438 return wrapped
439 return wrapper
440
441
442@region_protected(rh.Dossier)
3ebc0952 443def dossier_apercu(request, dossier_id):
baf9b78c 444 d = get_object_or_404(rh.Dossier, pk=dossier_id)
3ebc0952
OL
445 c = {
446 'is_popup' : request.GET.get('_popup', False),
baf9b78c 447 'dossier' : d,
520ab455
JPC
448 'pieces' : rh.DossierPiece.objects.filter(dossier__exact=d),
449 'contrats' : rh.Contrat.objects.filter(dossier__exact=d),
2a36598b 450 'commentaires' : rh.DossierCommentaire.objects.filter(dossier__exact=d).all(),
abf91905 451 'media_url': settings.PRIVE_MEDIA_URL,
3ebc0952
OL
452 }
453 return render_to_response('admin/rh/dossier/apercu.html', c, RequestContext(request))
4a1f2ece 454
fbe60a9d
OL
455@region_protected(rh.Poste)
456def poste_apercu(request, poste_id):
457 c = {
458 'is_popup' : request.GET.get('_popup', False),
0dcfc806
JPC
459 'poste' : get_object_or_404(rh.Poste, pk=poste_id),
460 'financements' : rh.PosteFinancement.objects.filter(poste=poste_id).all(),
461 'pieces' : rh.PostePiece.objects.filter(poste=poste_id).all(),
462 'dossiers' : rh.Dossier.objects.filter(poste=poste_id).order_by("-date_debut").all(),
463 'comparaisons' : rh.PosteComparaison.objects.filter(poste=poste_id).all(),
464 'commentaires' : rh.PosteCommentaire.objects.filter(poste=poste_id).all(),
abf91905 465 'media_url': settings.PRIVE_MEDIA_URL,
fbe60a9d
OL
466 }
467 return render_to_response('admin/rh/poste/apercu.html', c, RequestContext(request))
468
4a1f2ece
OL
469def employe_apercu(request, employe_id):
470 employe = get_object_or_404(rh.Employe, pk=employe_id)
fbe60a9d 471 user_groups = request.user.groups.all()
fbe60a9d
OL
472 dossiers = None
473
474 if request.user.is_superuser or \
475 grp_drh in user_groups:
476 q = Q(employe=employe)
477 if grp_correspondants_rh in user_groups:
7eeafa57 478 regions = [d.poste.implantation.region for d in employe.rh_dossiers.all()]
fbe60a9d 479 q = Q(employe=employe) & Q(implantation__region__in=regions)
22343fe7
OL
480
481 dossiers = rh.Dossier.objects.filter(q).order_by('-date_debut')
482
4a1f2ece
OL
483 c = {
484 'is_popup' : request.GET.get('_popup', False),
485 'employe' : employe,
fbe60a9d 486 'dossiers' : dossiers,
abf91905 487 'media_url': settings.PRIVE_MEDIA_URL,
4a1f2ece
OL
488 }
489 return render_to_response('admin/rh/employe/apercu.html', c, RequestContext(request))
150d83ec 490
77bd83d1
JPC
491@login_required
492@drh_or_admin_required
56264a85 493def organigrammes_employe(request, id, level="all"):
08faf06e
JPC
494
495 poste = get_object_or_404(rh.Poste, pk=id)
5c0f1778
JPC
496 dossiers_by_poste = dict((d.poste_id, d) for d in rh.Dossier.objects.select_related('employe', 'poste').all())
497 postes_by_id = dict((p.id, p) for p in rh.Poste.objects.all())
498
499 e = dossiers_by_poste[poste.id].employe
500 name = u"Organigramme de [%s] %s %s" % (e.id, e.nom.upper(), e.prenom)
58014aec 501 graph = pgv.AGraph()
5c0f1778 502
f187a10f 503 if rh.Poste.objects.filter(responsable=poste).count() > 0:
58014aec
JPC
504 postes_handle = [poste]
505 while postes_handle:
506 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 507
58014aec
JPC
508 for p in postes_handle:
509 if p.responsable_id != p.id:
510 graph.add_edge(dossiers_by_poste[p.responsable_id].poste_id, p.id)
13ad5ad5 511
f187a10f 512 else:
5c0f1778
JPC
513 graph.add_node(poste.id)
514
4afec2e1
JPC
515 if level != "all":
516 postes_niveau = [poste.id]
517 for niveau in range(int(level)):
518 postes_niveau = [p.id for p in rh.Poste.objects.filter(responsable__in=postes_niveau).all()]
519
520 while postes_niveau:
521 postes_niveau = [p.id for p in rh.Poste.objects.filter(responsable__in=postes_niveau).all()]
522 if postes_niveau:
523 for p in postes_niveau:
524 if graph.has_node(p):
525 graph.remove_node(p)
526
58014aec 527 a = graph
4afec2e1 528 a.name = name.encode('ascii', 'xmlcharrefreplace')
5c0f1778
JPC
529
530 poste_remontant = poste
531 while poste_remontant.responsable_id:
532 a.add_edge(poste_remontant.responsable_id, poste_remontant.id)
533 poste_remontant = poste_remontant.responsable
534
535 rh_graph.bind_poste_to_graph(a, postes_by_id)
536 #a.graph_attr['normalize'] = True
537 #a.graph_attr['level'] = 2
538 a.layout(prog='dot')
539
540 svg = a.draw(format='svg')
541
542 c = {
543 'svg': svg
544 }
a251ac8d
JPC
545
546 if 'forcer' in request.GET:
547 response = HttpResponse(svg, mimetype='image/svg+xml')
548 response['Content-Disposition'] = 'attachment; filename=organigramme.svg'
549 return response
550
c548bef6 551 return render_to_response('rh/organigrammes/employe.html', c, RequestContext(request), mimetype="image/svg+xml")
5c0f1778
JPC
552
553
554@login_required
555@drh_or_admin_required
556def organigrammes_service(request, id):
557
558 service = get_object_or_404(rh.Service, pk=id)
82af5c19
JPC
559 svg = rh_graph.organigramme_postes_cluster( \
560 cluster_filter={"service": service}, \
561 titre=u"Organigramme du service %s" % service.nom,
562 cluster_titre=service.nom)
5c0f1778 563
82af5c19
JPC
564 c = {
565 'svg': svg
566 }
5c0f1778 567
6dec02db 568 return render_to_response('rh/organigrammes/vide.html', c, RequestContext(request), mimetype="image/svg+xml")
5c0f1778 569
82af5c19
JPC
570@login_required
571@drh_or_admin_required
572def organigrammes_implantation(request, id):
5c0f1778 573
82af5c19
JPC
574 implantation = get_object_or_404(ref.Implantation, pk=id)
575 svg = rh_graph.organigramme_postes_cluster( \
576 cluster_filter={"implantation": implantation}, \
577 titre=u"Organigramme de l'implantation %s" % implantation.nom,
578 cluster_titre=implantation.nom)
5c0f1778
JPC
579
580 c = {
581 'svg': svg
582 }
583
6dec02db 584 return render_to_response('rh/organigrammes/vide.html', c, RequestContext(request), mimetype="image/svg+xml")
5c0f1778 585
9da4c195
JPC
586@login_required
587@drh_or_admin_required
588def organigrammes_region(request, id):
589
590 region = get_object_or_404(ref.Region, pk=id)
591 svg = rh_graph.organigramme_postes_cluster( \
592 cluster_filter={"implantation__region": region}, \
593 titre=u"Organigramme du bureau de %s" % region.nom,
594 cluster_titre=region.nom)
595
596 c = {
597 'svg': svg
598 }
599
600 return render_to_response('rh/organigrammes/vide.html', c, RequestContext(request), mimetype="image/svg+xml")