From: PA Parent Date: Wed, 30 Nov 2011 20:32:35 +0000 (-0500) Subject: Total des remun trans-dossiers X-Git-Tag: DAE+RH~238^2~21 X-Git-Url: http://git.auf.org/?p=auf_rh_dae.git;a=commitdiff_plain;h=2d5533acd298b274809efad36874e85f1ae6bcf3 Total des remun trans-dossiers --- diff --git a/project/rh/lib.py b/project/rh/lib.py index 0d4d8dc..9cb2e14 100644 --- a/project/rh/lib.py +++ b/project/rh/lib.py @@ -357,6 +357,8 @@ class EmployeAdmin(AUFMetadataAdminMixin, ProtectRegionMixin, admin.ModelAdmin): }), ) + add_form_template = 'admin/change_form.html' + def save_formset(self, request, form, formset, change): instances = formset.save(commit=False) for instance in instances: @@ -364,6 +366,41 @@ 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): pass diff --git a/project/rh/templates/admin/rh/employe/change_form.html b/project/rh/templates/admin/rh/employe/change_form.html new file mode 100644 index 0000000..fc49f2a --- /dev/null +++ b/project/rh/templates/admin/rh/employe/change_form.html @@ -0,0 +1,26 @@ +{% extends 'admin/change_form.html' %} + +{% block content %} +{{ block.super }} + +

Rémunération cette année

+ + + + + + +{% for t, m in remun.iteritems %} + + + + + +{% endfor %} + + + + +
Devise localeEuro
{{ t }}{{ m.0 }}{{ m.1 }}
Total{{ remun_sum }}{{ remun_sum_euro }}
+ +{% endblock %}