Ajout de la date dans les logs v2

This commit is contained in:
Bryce Tichit 2014-08-12 19:01:34 +02:00
parent 73928c98c2
commit 29ae32e0be
2 changed files with 7 additions and 7 deletions

View File

@ -62,24 +62,24 @@ class GroupController(AuthenticatedBaseController):
def grace_cotisation(self, group_cn): def grace_cotisation(self, group_cn):
group = Groupes.get_by_cn(self.user, self.user.residence_dn, 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) print("[LOG "+datetime.now().strftime("%Y-%m-%d %H:%M")+"] start grace du groupe "+ group.dn + " par l'admin "+ self.user.attrs.dn)
for user_dn in group.get('uniqueMember').all(): for user_dn in group.get('uniqueMember').all():
current_year = CotisationComputes.current_year() current_year = CotisationComputes.current_year()
cotisations = Cotisation.cotisations_of_member(self.user, user_dn, current_year) cotisations = Cotisation.cotisations_of_member(self.user, user_dn, current_year)
for cotisation in cotisations: for cotisation in cotisations:
if cotisation.has('x-paymentCashed') and cotisation.get('x-paymentCashed').first() == 'TRUE': 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) print("[LOG "+datetime.now().strftime("%Y-%m-%d %H:%M")+"] impossible de gracier une cotisation encaissee pour l'utilisateur "+ user_dn + " par l'admin "+ self.user.attrs.dn)
else: else:
old_montant = cotisation.get("x-amountPaid").first() old_montant = cotisation.get("x-amountPaid").first()
cotisation.get("x-amountPaid").replace(cotisation.get("x-amountPaid").first(), 0) cotisation.get("x-amountPaid").replace(cotisation.get("x-amountPaid").first(), 0)
self.user.ldap_bind.save(cotisation) 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) print("[LOG "+datetime.now().strftime("%Y-%m-%d %H:%M")+"] cotisation graciee (" + old_montant + "EUR) pour l'utilisateur "+ user_dn + " par l'admin "+ self.user.attrs.dn)
#end if #end if
#end for(cotisation) #end for(cotisation)
#end for(users) #end for(users)
print("[LOG] fin du grace_bulk_action du groupe "+ group.dn + " par l'admin "+ self.user.attrs.dn) print("[LOG "+datetime.now().strftime("%Y-%m-%d %H:%M")+"] fin du grace_bulk_action du groupe "+ group.dn + " par l'admin "+ self.user.attrs.dn)
redirect("/administration/") redirect("/administration/")
#end def #end def

View File

@ -37,7 +37,7 @@ def disconnect_members_from_residence(admin_user, residence_dn):
for dhcp_item in dhcps: for dhcp_item in dhcps:
if dhcp_item.uid.first() == machine_membre_tag: if dhcp_item.uid.first() == machine_membre_tag:
print("[LOG] scheduler disable machine " + dhcp_item.get("dhcpHWAddress").values[0] + " pour l'utilisateur "+ member.dn + " -- "+ dhcp_item.dn) print("[LOG "+datetime.now().strftime("%Y-%m-%d %H:%M")+"] scheduler disable machine " + dhcp_item.get("dhcpHWAddress").values[0] + " pour l'utilisateur "+ member.dn + " -- "+ dhcp_item.dn)
dhcp_item.uid.replace(machine_membre_tag, machine_membre_tag + "_disabled") dhcp_item.uid.replace(machine_membre_tag, machine_membre_tag + "_disabled")
admin_user.ldap_bind.save(dhcp_item) admin_user.ldap_bind.save(dhcp_item)
#end if #end if
@ -54,13 +54,13 @@ def disconnect_members_from_residence(admin_user, residence_dn):
for machine in machines: for machine in machines:
dns = Machine.get_dns_by_id(admin_user, machine.dn) dns = Machine.get_dns_by_id(admin_user, machine.dn)
ip = IpReservation.get_ip(admin_user, residence_dn, dns.dlzData.first()) ip = IpReservation.get_ip(admin_user, residence_dn, dns.dlzData.first())
print("[LOG] suppression machine " + Machine.get_dhcps(admin_user, machine.dn)[0].get("dhcpHWAddress").values[0] + " pour l'utilisateur "+ member.dn + " par le scheduler") print("[LOG "+datetime.now().strftime("%Y-%m-%d %H:%M")+"] suppression machine " + Machine.get_dhcps(admin_user, machine.dn)[0].get("dhcpHWAddress").values[0] + " pour l'utilisateur "+ member.dn + " par le scheduler")
#sys.stdout.flush() #sys.stdout.flush()
admin_user.ldap_bind.delete_entry_subtree(machine.dn) admin_user.ldap_bind.delete_entry_subtree(machine.dn)
if ip is not None: if ip is not None:
taken_attribute = ip.get("x-taken").first() taken_attribute = ip.get("x-taken").first()
if taken_attribute is not None: if taken_attribute is not None:
print ("[LOG] deleting taken_attribute") print ("[LOG "+datetime.now().strftime("%Y-%m-%d %H:%M")+"] deleting taken_attribute")
admin_user.ldap_bind.delete_attr(ip.dn, IpReservation.taken_attr(taken_attribute)) admin_user.ldap_bind.delete_attr(ip.dn, IpReservation.taken_attr(taken_attribute))
#end if #end if
#end if #end if