本文整理汇总了Python中models.Vote.details方法的典型用法代码示例。如果您正苦于以下问题:Python Vote.details方法的具体用法?Python Vote.details怎么用?Python Vote.details使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Vote
的用法示例。
在下文中一共展示了Vote.details方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GET
# 需要导入模块: from models import Vote [as 别名]
# 或者: from models.Vote import details [as 别名]
def GET(self, seq, pos):
count = Vote.count(web.ctx.game.id, seq, pos)
comments = Comment.details(web.ctx.game.id, seq, pos)
votes = Vote.details(web.ctx.game.id, seq, pos)
all_comments = {}
for c in comments:
all_comments[(c.rating, c.name)] = (c.notes, 'comment')
for v in votes:
all_comments[(v.rating, v.name)] = (v.notes, 'vote')
sorted_comments = sorted(
all_comments.iteritems(),
key=lambda ((rating, name), _): -rating,
)
return json.dumps({
'display_pos': Pretty.pos(pos),
'count': count,
'votes': [
{
'name': name,
'rating': Pretty.rating(rating),
'notes': notes,
'type': note_type,
}
for (rating, name), (notes, note_type) in sorted_comments
],
})
示例2: GET
# 需要导入模块: from models import Vote [as 别名]
# 或者: from models.Vote import details [as 别名]
def GET(self):
game = Game.current()
web.header(
'Content-Disposition',
'attachment; filename="ConGo-game-%s.sgf"' % (game.id,),
)
web.header('Content-Type', 'application/x-go-sgf')
data = [
'(;GM[1]FF[4]CA[UTF-8]AP[ConGo:0.1]ST[2]',
'RU[Japanese]SZ[19]KM[6.50]',
'GN[ConGo Game %s]PW[White Team]PB[Black Team]' % (game.id,),
'CP[2015 Jay Chan]RO[%s]' % (game.id),
]
end_seq = game.current_seq + 1
for seq in range(1, end_seq):
vote_counts = Vote.summary(game.id, seq)
show_current_move = seq < end_seq - 1
if seq > 1:
data.append(';%s[%s]' % (
(seq - 1) % 2 == 1 and 'B' or 'W',
prev_chosen_move,
))
if show_current_move:
data.append('LB')
vote_data = []
for i, vote in enumerate(list(vote_counts)[:7]):
label = chr(i + 65)
if i == 0:
chosen_move = vote.move
if vote.move != 'tt':
if show_current_move:
data.append('[%s:%s]' % (vote.move, label))
vote_data.append('%s: %s votes\n' % (label, vote.cnt))
else:
vote_data.append('Pass: %s votes\n' % (vote.cnt,))
if seq == 1:
data.append('C[con-go.net\n\n')
else:
data.append('C[')
votes = Vote.details(game.id, seq - 1, prev_chosen_move)
for vote in list(votes)[:5]:
data.append('%s (%s)\\: ' % (vote.name, Pretty.rating(vote.rating)))
notes = re.sub('\n', ' ', vote.notes)
notes = re.sub('\[', '(', notes)
notes = re.sub('\]', ')', notes)
notes = re.sub(r'\\', '\\\\', notes)
notes = re.sub(r':', '\\:', notes)
data.append(notes + '\n\n')
data.append('\n')
if show_current_move:
data.extend(vote_data)
data.append(']')
prev_chosen_move = chosen_move
data.append(')')
return ''.join(data)