accueil et mon profil
[auf_rh_dae.git] / project / rh / views.py
1 # -*- encoding: utf-8 -*-
2 from datetime import date
3 from django.contrib.auth.decorators import login_required
4 from django.shortcuts import redirect, render_to_response, get_object_or_404
5 from django.template import RequestContext
6
7 from datamaster_modeles import models as ref
8 from project.lib import get_employe_from_id
9
10 from rh import models as rh
11
12 # homes
13 @login_required
14 def profil(request):
15 """Profil personnel de l'employé - éditable"""
16 rc = RequestContext(request)
17 c = {}
18
19 employe = rc['this_employe']
20
21 # dossiers en cours
22 today = date.today()
23 dossiers_encours = employe.dossiers.all().exclude(date_debut__gt=today) \
24 .exclude(date_fin__lt=today)
25
26 c['user'] = request.user
27 c['employe'] = employe
28 c['dossiers_encours'] = dossiers_encours
29 return render_to_response('rh/profil.html', c, rc)
30
31 # employes
32 @login_required
33 def employes_liste(request):
34 """Liste des employés."""
35 employes = rh.Employe.objects.all()
36 c = {
37 'user':request.user,
38 'employes':employes,
39 }
40 return render_to_response('rh/employes_liste.html', c, RequestContext(request))
41
42 @login_required
43 def employe(request, id):
44 """Information publique sur un employé."""
45 try:
46 employe = rh.Employe.objects.get(pk=id)
47 except:
48 employe = rh.Employe.objects.none()
49 c = {
50 'user':request.user,
51 'employe':employe,
52 }
53 return render_to_response('rh/employe.html', c, RequestContext(request))