Commit dab37d8a authored by frekk's avatar frekk

fix bugs breaking the cokelog sync function

parent 8aab44da
......@@ -129,14 +129,14 @@ def refresh_dispense_payment(modeladmin, request, queryset):
num_changed = 0
membership_list = list(queryset)
for ms in membership_list:
if ms.date_paid is not None:
if ms.date_paid is not None or ms.username == '' or ms.username is None:
continue
if try_update_from_dispense(ms):
ms.save()
num_changed += 1
if num_changed > 0:
messages.success(request, "Updated %d records" % num_changed)
messages.success(request, "Updated %d records of %d total" % (num_changed, len(membership_list)))
else:
messages.warning(request, "No records updated")
......
......@@ -75,7 +75,7 @@ class CokeLog:
self.last_offset = self.file.tell()
def get_last_dispense(self, username, item_code=None, dispense_by=None):
if self.dispenses is None:
if self.dispenses is None or not username in self.dispenses:
return None
for r in reversed(self.dispenses[username]):
......@@ -105,7 +105,6 @@ def try_update_from_dispense(membership):
ms_disp = member_cokelog.get_last_dispense(
membership.member.username,
membership.get_dispense_item(),
None,
)
if ms_disp is not None:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment