Rapport: Premier jet
authorPA Parent <paparent@paparent.me>
Wed, 7 Dec 2011 20:38:11 +0000 (15:38 -0500)
committerPA Parent <paparent@paparent.me>
Wed, 7 Dec 2011 20:38:11 +0000 (15:38 -0500)
project/rh/models.py
project/rh/templates/rh/rapports/postes.html [new file with mode: 0644]
project/rh/urls.py
project/rh/views.py

index 18003e2..7ea2bc1 100644 (file)
@@ -535,7 +535,8 @@ class Dossier_(AUFMetadata):
     employe = models.ForeignKey('Employe', db_column='employe', 
                             related_name='dossiers',
                             verbose_name=u"Employé")
-    poste = models.ForeignKey('Poste', db_column='poste', related_name='+')
+    # TODO: OneToOne ??
+    poste = models.ForeignKey('Poste', db_column='poste', related_name='dossiers')
     statut = models.ForeignKey('Statut', related_name='+', default=3,
                             null=True)
     organisme_bstg = models.ForeignKey('OrganismeBstg', 
diff --git a/project/rh/templates/rh/rapports/postes.html b/project/rh/templates/rh/rapports/postes.html
new file mode 100644 (file)
index 0000000..b0ce839
--- /dev/null
@@ -0,0 +1,37 @@
+{% extends 'admin/base_site.html' %}
+{% load i18n %}
+
+{% block breadcrumbs %}{% if not is_popup %}
+<div class="breadcrumbs">
+       <a href="../../../">{% trans "Home" %}</a> &rsaquo;
+       <a href="../../">Rh</a> &rsaquo;
+       Rapport Postes
+</div>
+{% endif %}{% endblock %}
+
+{% block content %}
+<div id="content-main">
+
+       <table>
+       <tr>
+               <th># du poste</th>
+               <th>Nom du poste</th>
+               <th>Implantation</th>
+               <th># de l'employé</th>
+               <th>Nom</th>
+               <th>Prénom</th>
+       </tr>
+       {% for poste in postes %}
+       <tr>
+               <td>{{ poste.id }}</td>
+               <td>{{ poste.nom }}</td>
+               <td>{{ poste.implantation }}</td>
+               <td>{{ poste.employe_id }}</td>
+               <td>{{ poste.employe_nom }}</td>
+               <td>{{ poste.employe_prenom }}</td>
+       </tr>
+       {% endfor %}
+       </table>
+
+</div>
+{% endblock %}
index d7f925f..5e92fe9 100644 (file)
@@ -12,3 +12,8 @@ urlpatterns += patterns(
     'project.rh.api',
     url(r'^employes/(?P<id>\d+)/photo$', 'photo', name='rh_photo'),
 )
+# Rapports
+urlpatterns += patterns(
+    'project.rh.views',
+    url(r'^admin/rh/rapports/postes$', 'rapports_poste', name='rhr_postes'),
+)
index d623ef6..2f05329 100644 (file)
@@ -52,3 +52,38 @@ def employe(request, id):
         'employe':employe,
         }
     return render_to_response('rh/employe.html', c, RequestContext(request))
+
+
+# Rapports
+
+@login_required
+def rapports_poste(request):
+
+    postes = rh.Poste.actifs.select_related('implantation').all()
+    poste_ids = set([p.pk for p in postes])
+
+    dossiers = rh.Dossier.objects.select_related('poste', 'employe').filter(poste__in=poste_ids)
+
+    employes = dict((d.poste.id, d.employe) for d in dossiers)
+
+    out = []
+
+    for p in postes:
+        line = {}
+        out.append(line)
+
+        line['id'] = p.id
+        line['nom'] = p.nom
+        line['implantation'] = p.implantation.nom
+        employe = employes.get(p.id)
+        if employe:
+            line['employe_id'] = employe.id
+            line['employe_nom'] = employe.nom
+            line['employe_prenom'] = employe.prenom
+
+    c = {
+        'title': 'Rapport des postes',
+        'postes': out,
+    }
+
+    return render_to_response('rh/rapports/postes.html', c, RequestContext(request))