def get(self): self.render('bets', { 'bets': Bet.all()\ .filter('state != ', 'withdrawn')\ .filter('state != ', 'rejected') #.order('-# created_at') })
def post(self): bet = Bet.get(self.request.get('bet_key')) action = self.request.get('response') if self.user == bet.bettee: if action == "Accept": bet.bettee_accept() elif action == "Reject": bet.bettee_reject() elif action == "Won": bet.bettee_win() elif action == "Drawn": bet.bettee_drawn() elif action == "Lost": bet.bettee_lost() elif action == "Hide": bet.bettee_hide() elif self.user == bet.better: if action == "Accept": bet.better_accept() elif action == "Reject": bet.better_reject() elif action == "Withdraw": bet.withdraw_bet() elif action == "Won": bet.better_win() elif action == "Drawn": bet.better_drawn() elif action == "Lost": bet.better_lost() elif action == "Hide": bet.better_hide() else: self.error(500) return bet.put() self.redirect_back()
def post(self): email = self.request.get('email') bettee = User.all().filter('email', email).get() if bettee: self.redirect("/user/%s" % bettee.key()) return bettee = User( displayName = self.request.get('bettee'), email = email, claim_token = str(uuid()), verified = False ) bettee.put() bet = Bet( better = self.user, bettee = bettee, better_amount = self.request.get('better_amount'), bettee_amount = self.request.get('bettee_amount'), description = self.request.get('description') ) bet.put() mail.send_mail(sender = "'%s (%s)' <%s>" % (self.user, self.host, "'Glenn Murray (creator of vconomy)' <*****@*****.**>"), to = bettee.email, subject="%s: %s bet you $%s that '%s'" % (self.host, self.user, bet.better_amount, bet.description), body=""" Hello from %s! %s [via %s] (http://%s/user/%s) has bet you %s virtual dollars that "%s". To respond to this bet, go here http://%s/claim/%s and respond! Creating an account is simple, we support logging in via Google, Facebook, Yahoo, Twitter and OpenID. Hope to see you online, - %s (via %s) """ % (self.host, self.user, self.user.providerName, self.host, self.user.key(), bet.better_amount, bet.description, self.host, bettee.claim_token, self.user, self.host)) self.redirect('/user/%s' % bettee.key())