rh.api.photo sans logique accès
[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."""
5ea6b5bb 45 today = date.today()
46 employes = rh.Employe.objects \
47 .filter(actif=True, supprime=False) \
48 .filter(dossiers__actif=True, dossiers__supprime=False) \
49 .exclude(dossiers__date_debut__gt=today) \
50 .exclude(dossiers__date_fin__lt=today) \
51 .order_by('nom')
a9faef67 52 c = {
53 'user':request.user,
54 'employes':employes,
55 }
56 return render_to_response('rh/employes_liste.html', c, RequestContext(request))
57
3411ac33 58@login_required
a9faef67 59def employe(request, id):
60 """Information publique sur un employé."""
61 try:
62 employe = rh.Employe.objects.get(pk=id)
63 except:
64 employe = rh.Employe.objects.none()
65 c = {
66 'user':request.user,
67 'employe':employe,
68 }
69 return render_to_response('rh/employe.html', c, RequestContext(request))