Merge branch 'dev' of ssh://git.auf/auf_rh_dae into dev
[auf_rh_dae.git] / project / rh / views.py
CommitLineData
e9bbd6ba 1# -*- encoding: utf-8 -*-
c9122f1d 2from datetime import date
9b0a8554 3
3411ac33 4from django.contrib.auth.decorators import login_required
e9bbd6ba 5from django.shortcuts import redirect, render_to_response, get_object_or_404
6from django.template import RequestContext
7
d04d084c 8from datamaster_modeles import models as ref
d04d084c 9from project.lib import get_employe_from_id
ae936f8d 10
d04d084c 11from rh import models as rh
a9faef67 12
3411ac33 13# homes
c9122f1d 14@login_required
15def profil(request):
16 """Profil personnel de l'employé - éditable"""
17 rc = RequestContext(request)
18 c = {}
d04d084c 19
c9122f1d 20 employe = rc['this_employe']
21
9b0a8554 22 # dossiers en cours et passés
c9122f1d 23 today = date.today()
9b0a8554 24 dossiers = employe.dossiers.all().order_by('-date_fin')
25 dossiers_passes = dossiers.filter(date_fin__lt=today)
26 dossiers_futurs = dossiers.filter(date_debut__gt=today)
27 dossiers_p_f = dossiers_passes | dossiers_futurs
28 ids_dossiers_p_f = [d.id for d in dossiers_p_f]
29 dossiers_encours = dossiers.exclude(id__in=ids_dossiers_p_f)
30
31 for d in dossiers_passes:
32 d.archive = True
c9122f1d 33
34 c['user'] = request.user
35 c['employe'] = employe
9b0a8554 36 c['dossiers'] = dossiers.count()
37 c['dossiers_passes'] = dossiers_passes
c9122f1d 38 c['dossiers_encours'] = dossiers_encours
39 return render_to_response('rh/profil.html', c, rc)
a9faef67 40
41# employes
3411ac33 42@login_required
a9faef67 43def employes_liste(request):
44 """Liste des employés."""
45 employes = rh.Employe.objects.all()
46 c = {
47 'user':request.user,
48 'employes':employes,
49 }
50 return render_to_response('rh/employes_liste.html', c, RequestContext(request))
51
3411ac33 52@login_required
a9faef67 53def employe(request, id):
54 """Information publique sur un employé."""
55 try:
56 employe = rh.Employe.objects.get(pk=id)
57 except:
58 employe = rh.Employe.objects.none()
59 c = {
60 'user':request.user,
61 'employe':employe,
62 }
63 return render_to_response('rh/employe.html', c, RequestContext(request))