correction de quelques erreurs sur la registration et le quick_pick_last add
ajout de quelques gardes fous pour éviter d'avoir des exceptions de partout
This commit is contained in:
parent
20c383239d
commit
c71ada2b8b
@ -75,9 +75,27 @@ class MemberAddController(AuthenticatedRestController):
|
|||||||
phone = ' '
|
phone = ' '
|
||||||
#end if
|
#end if
|
||||||
|
|
||||||
member = Member.entry_attr(member_uid, prenom, nom, mail, phone, -1)
|
|
||||||
|
|
||||||
residence_dn = Residences.get_dn_by_name(self.user, residence)
|
residence_dn = Residences.get_dn_by_name(self.user, residence)
|
||||||
|
|
||||||
|
# On modifie silencieusement le nom de la machine si il existe déjà
|
||||||
|
def try_name(name, number):
|
||||||
|
actual_name = name
|
||||||
|
if number > 0:
|
||||||
|
actual_name = name + str(number)
|
||||||
|
#end if
|
||||||
|
|
||||||
|
member = Member.get_by_uid(self.user, residence_dn, actual_name)
|
||||||
|
if member is not None:
|
||||||
|
return try_name(name, number + 1)
|
||||||
|
else:
|
||||||
|
return actual_name
|
||||||
|
#end if
|
||||||
|
#endif
|
||||||
|
|
||||||
|
member_uid = try_name(member_uid, 0)
|
||||||
|
|
||||||
|
|
||||||
|
member = Member.entry_attr(member_uid, prenom, nom, mail, phone, -1)
|
||||||
|
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
year = 0
|
year = 0
|
||||||
@ -864,9 +882,10 @@ class RoomMoveController(AuthenticatedRestController):
|
|||||||
else:
|
else:
|
||||||
old_room = Room.get_by_member_dn(self.user, residence_dn, member.dn)
|
old_room = Room.get_by_member_dn(self.user, residence_dn, member.dn)
|
||||||
memberIn_attribute = Room.memberIn_attr(str(member.dn))
|
memberIn_attribute = Room.memberIn_attr(str(member.dn))
|
||||||
self.user.ldap_bind.delete_attr(old_room.dn, memberIn_attribute)
|
if old_room is not None:
|
||||||
|
self.user.ldap_bind.delete_attr(old_room.dn, memberIn_attribute)
|
||||||
print("[LOG] retrait de chambre pour le member "+member_uid+" from "+ old_room.uid.first() +" by "+self.user.attrs.dn)
|
print("[LOG] retrait de chambre pour le member "+member_uid+" from "+ old_room.uid.first() +" by "+self.user.attrs.dn)
|
||||||
|
#end if
|
||||||
#end if
|
#end if
|
||||||
|
|
||||||
#self.user.ldap_bind.delete_entry_subtree(machine.dn)
|
#self.user.ldap_bind.delete_entry_subtree(machine.dn)
|
||||||
|
@ -24,7 +24,7 @@ class RegistrationController(AuthenticatedBaseController):
|
|||||||
|
|
||||||
member_edit_controller = None
|
member_edit_controller = None
|
||||||
|
|
||||||
quick_last_registrations = []
|
quick_last_registrations = dict()
|
||||||
|
|
||||||
def __init__(self, member_edit_controller):
|
def __init__(self, member_edit_controller):
|
||||||
self.new = NewRegistrationController(member_edit_controller)
|
self.new = NewRegistrationController(member_edit_controller)
|
||||||
@ -91,11 +91,17 @@ class RegistrationController(AuthenticatedBaseController):
|
|||||||
|
|
||||||
extras_available = Cotisation.get_all_extras(self.user, self.user.residence_dn)
|
extras_available = Cotisation.get_all_extras(self.user, self.user.residence_dn)
|
||||||
|
|
||||||
|
if residence in RegistrationController.quick_last_registrations:
|
||||||
|
quick_last = RegistrationController.quick_last_registrations[residence]
|
||||||
|
else:
|
||||||
|
quick_last = []
|
||||||
|
#end if
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"user" : self.user,
|
"user" : self.user,
|
||||||
"residence" : residence,
|
"residence" : residence,
|
||||||
"rooms" : rooms,
|
"rooms" : rooms,
|
||||||
"quick_last" : RegistrationController.quick_last_registrations,
|
"quick_last" : quick_last,
|
||||||
"available_months_prices" : available_months_prices,
|
"available_months_prices" : available_months_prices,
|
||||||
"extras_available" : extras_available
|
"extras_available" : extras_available
|
||||||
}
|
}
|
||||||
@ -152,10 +158,15 @@ class NewRegistrationController(AuthenticatedRestController):
|
|||||||
member = Member.get_by_uid(self.user, self.user.residence_dn, member_uid)
|
member = Member.get_by_uid(self.user, self.user.residence_dn, member_uid)
|
||||||
|
|
||||||
if member is not None:
|
if member is not None:
|
||||||
RegistrationController.quick_last_registrations.append(member)
|
if residence not in RegistrationController.quick_last_registrations:
|
||||||
|
RegistrationController.quick_last_registrations[residence] = []
|
||||||
|
#end if
|
||||||
|
RegistrationController.quick_last_registrations[residence].append(member)
|
||||||
#end if
|
#end if
|
||||||
|
|
||||||
self.member_edit_controller.room.move.post(residence, member_uid, room_uid, erase = True, go_redirect = False)
|
if room_uid != "":
|
||||||
|
self.member_edit_controller.room.move.post(residence, member_uid, room_uid, erase = True, go_redirect = False)
|
||||||
|
#end if
|
||||||
try:
|
try:
|
||||||
self.member_edit_controller.machine.add.post(residence, member_uid, first_machine_name, first_machine_mac, go_redirect = False)
|
self.member_edit_controller.machine.add.post(residence, member_uid, first_machine_name, first_machine_mac, go_redirect = False)
|
||||||
self.member_edit_controller.cotisation.add.post(residence, member_uid, next_end, extra_name, go_redirect = False)
|
self.member_edit_controller.cotisation.add.post(residence, member_uid, next_end, extra_name, go_redirect = False)
|
||||||
|
Loading…
Reference in New Issue
Block a user