本文整理汇总了Python中models.Match.player2方法的典型用法代码示例。如果您正苦于以下问题:Python Match.player2方法的具体用法?Python Match.player2怎么用?Python Match.player2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Match
的用法示例。
在下文中一共展示了Match.player2方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: confirm_match
# 需要导入模块: from models import Match [as 别名]
# 或者: from models.Match import player2 [as 别名]
def confirm_match(request, req_id=None):
if request.method == "POST":
if req_id is not None:
try:
sr = ScoreRequest.objects.get(id=req_id)
except:
return HttpResponseRedirect('/welcome/')
form = ConfirmRequestForm(request.POST, instance=sr)
print form
if form.is_valid() and sr.player2.user.username == request.user.username: #and needs to verify player2 is current player lol
form.save()
if int(request.POST['verified']) == 2:
#Save fields into a Match object now
match = Match()
match.player1 = sr.player1
match.player2 = sr.player2
match.wins = sr.wins
match.loss = sr.loss
match.ties = sr.ties
match.tournament = sr.tournament
match.save()
return HttpResponseRedirect('/welcome/')
return HttpResponseRedirect('/welcome/')
else:
print "Only POST requests for now"
return HttpResponseRedirect('/welcome/')
示例2: find
# 需要导入模块: from models import Match [as 别名]
# 或者: from models.Match import player2 [as 别名]
def find(id):
select = """
select p.fname, p.id, a.score, m.entered_time
from player p, attempt a, match m
where p.id = a.player_id
and a.match_id = ?
and m.id = a.match_id
"""
m = Match(id=id)
cur = g.db.execute(select, [id])
attempts = cur.fetchall()
player1 = Player(*attempts[0][:2])
m.player1 = player1
m.score1 = attempts[0][2]
player2 = Player(*attempts[1][:2])
m.player2 = player2
m.score2 = attempts[1][2]
m.entered_time = attempts[0][-1]
return m