ajout du grace en masse sur les groupes

This commit is contained in:
Romain Beuque 2014-06-08 23:03:36 +02:00
parent 1bf59a506b
commit ebb3dcbead
2 changed files with 27 additions and 0 deletions

View File

@ -56,6 +56,32 @@ class GroupController(AuthenticatedBaseController):
redirect("/administration/")
#end def
@expose()
def grace_cotisation(self, group_cn):
group = Groupes.get_by_cn(self.user, self.user.residence_dn, group_cn)
print("[LOG] start grace du groupe "+ group.dn + " par l'admin "+ self.user.attrs.dn)
for user_dn in group.get('uniqueMember').all():
current_year = CotisationComputes.current_year()
cotisations = Cotisation.cotisations_of_member(self.user, user_dn, current_year)
for cotisation in cotisations:
if cotisation.has('x-paymentCashed') and cotisation.get('x-paymentCashed').first() == 'TRUE':
print("[LOG] impossible de gracier une cotisation encaissee pour l'utilisateur "+ user_dn + " par l'admin "+ self.user.attrs.dn)
else:
old_montant = cotisation.get("x-amountPaid").first()
cotisation.get("x-amountPaid").replace(cotisation.get("x-amountPaid").first(), 0)
self.user.ldap_bind.save(cotisation)
print("[LOG] cotisation graciee (" + old_montant + "EUR) pour l'utilisateur "+ user_dn + " par l'admin "+ self.user.attrs.dn)
#end if
#end for(cotisation)
#end for(users)
print("[LOG] fin du grace_bulk_action du groupe "+ group.dn + " par l'admin "+ self.user.attrs.dn)
redirect("/administration/")
#end def
#end class

View File

@ -17,6 +17,7 @@
</py:when>
<py:otherwise>
<span class="enum_block" py:for="member in group.uniqueMember.values">${member} <a class="link_button" href="groups/delete_member/${group.cn.first()}/${member}">retirer</a></span>
<a href="groups/grace_cotisation/${group.cn.first()}" class="button">gracier le groupe</a>
</py:otherwise>
</div>
</div>