refact ergo + page perso (vide)
[auf_rh_dae.git] / project / rh / views.py
index 60f00ef..17530fb 100644 (file)
@@ -1 +1,47 @@
-# Create your views here.
+# -*- encoding: utf-8 -*-
+from django.contrib.auth.decorators import login_required
+from django.shortcuts import redirect, render_to_response, get_object_or_404
+from django.template import RequestContext
+
+#from datamaster_modeles import models as ref
+from project.rh import models as rh
+from project.decorators import user_is_this_employe
+
+
+# homes
+@user_is_this_employe
+def perso(request, id):
+    """Espace personnel de l'employé."""
+    try:
+        employe = rh.Employe.objects.get(pk=id)
+    except:
+        employe = rh.Employe.none()
+    c = {
+        'user':request.user,
+        'employe':employe,
+        }
+    return render_to_response('rh/perso.html', c, RequestContext(request))
+    
+# employes
+@login_required
+def employes_liste(request):
+    """Liste des employés."""
+    employes = rh.Employe.objects.all()
+    c = {
+        'user':request.user,
+        'employes':employes,
+        }
+    return render_to_response('rh/employes_liste.html', c, RequestContext(request))
+    
+@login_required
+def employe(request, id):
+    """Information publique sur un employé."""
+    try:
+        employe = rh.Employe.objects.get(pk=id)
+    except:
+        employe = rh.Employe.objects.none()
+    c = {
+        'user':request.user,
+        'employe':employe,
+        }
+    return render_to_response('rh/employe.html', c, RequestContext(request))