本文整理汇总了Python中models.Vote.gql方法的典型用法代码示例。如果您正苦于以下问题:Python Vote.gql方法的具体用法?Python Vote.gql怎么用?Python Vote.gql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Vote
的用法示例。
在下文中一共展示了Vote.gql方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: rawPost
# 需要导入模块: from models import Vote [as 别名]
# 或者: from models.Vote import gql [as 别名]
def rawPost(self, ballotID, voteID):
vote = self.getVote(ballotID, voteID)
id = self.request.get('release.id', default_value=None)
mbid = self.request.get('release.mbid', default_value=None)
if id:
vote.release = db.Key.from_path(Release.kind(), int(id))
elif mbid:
vote.release = Release.get(mbid)
else:
id = self.request.get('artist.id', default_value=None)
mbid = self.request.get('artist.mbid', default_value=None)
if id:
artist = db.Key.from_path(Artist.kind(), int(id))
elif mbid:
artist = Artist.get(mbid)
else:
artist = Artist(name=self.request.get('artist'),
sortname=self.request.get('sortname'))
artisturl = self.request.get('artisturl', default_value=None)
if artisturl:
artist.url = artisturl
artist.put()
release = Release(artist=artist, title=self.request.get('title'))
releaseurl = self.request.get('releaseurl', default_value=None)
if releaseurl:
release.url = releaseurl
release.put()
vote.release = release
vote.put()
next = Vote.gql('WHERE release = :1 ORDER BY artist', None).get()
if next:
key = next.key()
self.redirect('../%d/%d' % (key.parent().id(), key.id()))
else:
self.redirect('../..')
示例2: get
# 需要导入模块: from models import Vote [as 别名]
# 或者: from models.Vote import gql [as 别名]
def get(self, year):
poll = Poll.get(year)
if not poll:
self.response.out.write('No poll for ' + year + '.')
return
unc = []
for b in poll.ballots():
unc.extend(Vote.gql('WHERE ballot = :1 AND release = :2', b, None))
unc.sort(key=lambda v: v.artist.lower())
self.render('admin.html', poll=poll, unc=unc)