deplug calc in edit
authorOlivier Larchevêque <olivier.larcheveque@auf.org>
Mon, 9 Jan 2012 16:36:23 +0000 (11:36 -0500)
committerOlivier Larchevêque <olivier.larcheveque@auf.org>
Mon, 9 Jan 2012 16:36:23 +0000 (11:36 -0500)
project/rh/lib.py
project/rh/templates/admin/rh/dossier/change_form.html [deleted file]
project/rh/templates/admin/rh/employe/change_form.html [deleted file]

index c955f0a..1fd3da3 100644 (file)
@@ -280,8 +280,6 @@ class DossierAdmin(AUFMetadataAdminMixin, ProtectRegionMixin, admin.ModelAdmin,)
         }),
     )
 
-    add_form_template = 'admin/change_form.html'
-
     def queryset(self, request):
         return self.model.actifs.all()
 
@@ -319,29 +317,6 @@ class DossierAdmin(AUFMetadataAdminMixin, ProtectRegionMixin, admin.ModelAdmin,)
                 instance.owner = request.user
             instance.save()
 
-    def render_change_form(self, request, context, *args, **kwargs):
-        obj = kwargs.get('obj', None)
-
-        if not obj:
-            return super(DossierAdmin, self).render_change_form(request, context, *args, **kwargs)
-
-
-        remun, remun_sum, remun_sum_euro = calc_remun(obj)
-
-        extra = {
-            'remun': remun,
-            'remun_sum': remun_sum,
-            'remun_sum_euro': remun_sum_euro,
-            'employe': obj.employe,
-            'poste_nom': obj.poste.nom,
-            'poste_service': obj.poste.service,
-            'poste_implantation': obj.poste.implantation,
-        }
-
-        context.update(extra)
-
-        return super(DossierAdmin, self).render_change_form(request, context, *args, **kwargs)
-
 
 class DossierPieceAdmin(admin.ModelAdmin):
     pass
@@ -385,9 +360,6 @@ class EmployeAdmin(AUFMetadataAdminMixin, ProtectRegionMixin, admin.ModelAdmin):
         }),
         )
 
-    add_form_template = 'admin/change_form.html'
-
-
     def _nom(self, obj):
         view_link = reverse('employe_apercu', args=(obj.id,))
         edit_link = reverse('admin:rh_employe_change', args=(obj.id,))
@@ -427,39 +399,6 @@ class EmployeAdmin(AUFMetadataAdminMixin, ProtectRegionMixin, admin.ModelAdmin):
                 instance.owner = request.user
             instance.save()
 
-    def render_change_form(self, request, context, *args, **kwargs):
-        obj = kwargs.get('obj', None)
-
-        if not obj:
-            return super(EmployeAdmin, self).render_change_form(request, context, *args, **kwargs)
-
-        remun = {}
-        remun_sum = 0
-        remun_sum_euro = 0
-        dossiers = obj.dossiers.all()
-
-        for dossier in dossiers:
-            this_remun, this_remun_sum, this_remun_sum_euro = calc_remun(dossier)
-
-            for item in this_remun:
-                if item not in remun:
-                    remun[item] = this_remun[item]
-                else:
-                    remun[item][0] += this_remun[item][0]
-                    remun[item][1] += this_remun[item][1]
-
-            remun_sum += this_remun_sum
-            remun_sum_euro += this_remun_sum_euro
-
-        extra = {
-            'remun': remun,
-            'remun_sum': remun_sum,
-            'remun_sum_euro': remun_sum_euro,
-        }
-
-        context.update(extra)
-
-        return super(EmployeAdmin, self).render_change_form(request, context, *args, **kwargs)
 
 
 class EmployeCommentaireAdmin(admin.ModelAdmin):
diff --git a/project/rh/templates/admin/rh/dossier/change_form.html b/project/rh/templates/admin/rh/dossier/change_form.html
deleted file mode 100644 (file)
index f95c2cf..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-{% extends 'admin/change_form.html' %}
-
-{% block content %}
-<h2 id="testemploye">Employé: <a href="{% url admin:rh_employe_change employe.pk %}">{{ employe }}</a></h2>
-<h2>Poste</h2>
-<div class="form-row">
-       <label>Nom:</label> {{ poste_nom }}
-</div>
-<div class="form-row">
-       <label>Service:</label> {{ poste_service }}
-</div>
-<div class="form-row">
-       <label>Implantation:</label> {{ poste_implantation }}
-</div>
-
-{{ block.super }}
-
-<h2>Rémunération cette année</h2>
-<table>
-       <tr>
-               <th></th>
-               <th>Devise locale</th>
-               <th>Euro</th>
-       </tr>
-{% for t, m in remun.iteritems %}
-       <tr>
-               <td>{{ t }}</td>
-               <td>{{ m.0 }}</td>
-               <td>{{ m.1 }}</td>
-       </tr>
-{% endfor %}
-       <tr>
-               <td>Total</td>
-               <td>{{ remun_sum }}</td>
-               <td>{{ remun_sum_euro }}</td>
-</table>
-
-{% endblock %}
diff --git a/project/rh/templates/admin/rh/employe/change_form.html b/project/rh/templates/admin/rh/employe/change_form.html
deleted file mode 100644 (file)
index fc49f2a..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-{% extends 'admin/change_form.html' %}
-
-{% block content %}
-{{ block.super }}
-
-<h2>Rémunération cette année</h2>
-<table>
-       <tr>
-               <th></th>
-               <th>Devise locale</th>
-               <th>Euro</th>
-       </tr>
-{% for t, m in remun.iteritems %}
-       <tr>
-               <td>{{ t }}</td>
-               <td>{{ m.0 }}</td>
-               <td>{{ m.1 }}</td>
-       </tr>
-{% endfor %}
-       <tr>
-               <td>Total</td>
-               <td>{{ remun_sum }}</td>
-               <td>{{ remun_sum_euro }}</td>
-</table>
-
-{% endblock %}