Commit c611d2e7 authored by frekk's avatar frekk

add log messages for incorrect dispenses

parent 4a39e225
...@@ -10,7 +10,7 @@ if COKELOG is None: ...@@ -10,7 +10,7 @@ if COKELOG is None:
log.warning("COKELOG_PATH is not defined, cannot sync payment status from dispense to DB") log.warning("COKELOG_PATH is not defined, cannot sync payment status from dispense to DB")
ALL_REGEX = r"^(?P<date>[A-Za-z]{3}\s+\d+\s[\d:]{8})\s(\w+)\sodispense2:\sdispense '([^']+)' \((?P<item>(coke|pseudo|snack|door):(\d{1,3}))\) for (?P<for>\w+) by (?P<by>\w+) \[cost\s+(\d+), balance\s+(\d+)\]$" ALL_REGEX = r"^(?P<date>[A-Za-z]{3}\s+\d+\s[\d:]{8})\s(\w+)\sodispense2:\sdispense '([^']+)' \((?P<item>(coke|pseudo|snack|door):(\d{1,3}))\) for (?P<for>\w+) by (?P<by>\w+) \[cost\s+(\d+), balance\s+(\d+)\]$"
MEMBERSHIP_REGEX = r"^(?P<date>[A-Za-z]{3}\s+\d+\s[\d:]{8})\s(\w+)\sodispense2:\sdispense '([^']+)' \((?P<item>(pseudo):(\d{1,3}))\) for (?P<for>\w+) by (?P<by>\w+) \[cost\s+(\d+), balance\s+(\d+)\]$" MEMBERSHIP_REGEX = r"^(?P<date>[A-Za-z]{3}\s+\d+\s[\d:]{8})\s(\w+)\sodispense2:\sdispense '(membership [^']+)' \((?P<item>(pseudo):(\d{1,3}))\) for (?P<for>\w+) by (?P<by>\w+) \[cost\s+(\d+), balance\s+(\d+)\]$"
class CokeLog: class CokeLog:
regex = ALL_REGEX regex = ALL_REGEX
...@@ -83,7 +83,7 @@ class CokeLog: ...@@ -83,7 +83,7 @@ class CokeLog:
continue continue
if dispense_by is not None and r["by"] != dispense_by: if dispense_by is not None and r["by"] != dispense_by:
continue continue
return r["date"] return r
return None return None
# create a "static" instance of cokelog # create a "static" instance of cokelog
...@@ -105,15 +105,21 @@ def try_update_from_dispense(membership): ...@@ -105,15 +105,21 @@ def try_update_from_dispense(membership):
else: else:
member_cokelog.open() member_cokelog.open()
# look for entries like "dispense 'membership ...' (pseudo:) for <user> by <user> ..." # look for entries like "dispense 'membership ...' (pseudo:..) for <user> by <user> ..."
ms_disp = member_cokelog.get_last_dispense( ms_disp = member_cokelog.get_last_dispense(membership.member.username)
membership.member.username,
membership.get_dispense_item(),
)
if ms_disp is not None: if ms_disp is not None:
membership.date_paid = ms_disp if ms_disp['item'] != membership.get_dispense_item():
membership.payment_method = 'dispense' log.warn("user '%s': paid incorrect item '%s', not '%s' in dispense." % (
return True membership.member.username, ms_disp['item'], membership.get_dispense_item()
))
else:
membership.date_paid = ms_disp['date']
membership.payment_method = 'dispense'
log.debug("user '%s': paid in cokelog" % membership.member.username)
return True
else:
log.info("user '%s': no paid membership in cokelog" % membership.member.username)
return False return False
\ No newline at end of file
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