daily pastebin goal
5%
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def accept_status(req):
  2.     # status can be accepted only if
  3.     # 1 - the user owns the location
  4.     # 2 - the previous state is pending (0)
  5.     if req.status == 0 and req.offer.location.user_id == current_user.id:
  6.         hour_delta = (req.to_hour.hour - req.from_hour.hour)
  7.         if req.to_hour.minute - req.from_hour.minute > 30 or \
  8.                 req.from_hour.minute - req.to_hour.minute < -30:
  9.             hour_delta += 1
  10.         if req.offer.current_seats > 0 and req.user.wallet > 20 * hour_delta:
  11.             req.status = 1
  12.             req.offer.current_seats -= 1
  13.             req.user.wallet -= 20 * hour_delta
  14.             req.offer.location.user.wallet += 20 * hour_delta
  15.     return req
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top