Esempio n. 1
0
File: main.py Progetto: hassy/Mowars
 def post(self):
     
     loser = db.get(str(self.request.get('loser')))
     winner = db.get(str(self.request.get('winner')))
     vote = Vote(winner=winner, loser=loser)
     
     #To store username if the user is logged in
     client = OAuthClient("twitter", self)
     logged_in = client.get_cookie()
     
     if logged_in:
         info = client.get("/account/verify_credentials")
         vote.name = info["screen_name"]
     else:
         vote.name = 'Guest'
     
     #TODO: Stop spam-voting for same key from same ip repeatedly
     vote.ip = self.request.remote_addr
     
     if check_vote_spam(vote.ip, winner):
         self.redirect('/msg=You+appear+to+be+votespamming,+please+stop+or+try+again+later')
     else:
         vote.put()
     
         #Wins and losses
         loser.losses = loser.losses+1
         loser.win_percentage = loser.calc_win_percentage()
         loser.put()
     
         winner.wins = winner.wins+1
         winner.win_percentage = winner.calc_win_percentage()
         winner.put()
     
         #Redirect so that people cannot repost twice
         self.redirect('/?w=%s&l=%s' % (winner.key().id(), loser.key().id()))
Esempio n. 2
0
File: main.py Progetto: hassy/Mowars
 def get(self):
     win_key = str(self.request.get('k'))
     winner = db.get(win_key)
     ip = str(self.request.remote_addr)
     count = check_vote_spam(ip, winner)
     self.response.out.write(str(win_key)+' '+str(count)+' '+ip)