Changeset 117

Show
Ignore:
Timestamp:
04/13/08 21:39:25 (6 months ago)
Author:
nlawren2
Message:

Fixed authenticate_purchase in cardswipe.py. So far, it only checks if the tray's empty and whether the user has enough money.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sucrose/trunk/python/cardswipe.py

    r111 r117  
    1515 
    1616        def authenticate_purchase(self, location): 
    17                 return True # XXX wit, fix it 
    18  
     17                try: 
     18                        tray = self.sucrose.tray_from_location(location)) 
     19                except ValueError: 
     20                        raise 
     21                 
     22                if tray.quantity > 0: 
     23                        if self.sucrose.balance_for_user(self.sucrose.user_from_uin(self.uin)) >= tray.cur_price: 
     24                                return True 
     25                        raise ValueError('not enough money') 
     26                raise ValueError('tray is empty') 
    1927 
    2028        def authenticated_user(self):