本文整理汇总了Python中models.Vote.name方法的典型用法代码示例。如果您正苦于以下问题:Python Vote.name方法的具体用法?Python Vote.name怎么用?Python Vote.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Vote
的用法示例。
在下文中一共展示了Vote.name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import Vote [as 别名]
# 或者: from models.Vote import name [as 别名]
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()))