def get_vote(cls, page, language, group, author, voter):
"""
Retrieve a vote by page, language, group, author and voter
:param page: the page ID
:param language: the language ID
:param group: the group ID
:param author: the author ID
:param voter: the voter ID
:return: a vote or None
"""
if page is None or language is None or group is None\
or author is None or voter is None:
return None
try:
return cls.query.filter(
cls.page_id == page.id,
cls.language_id == language.id,
cls.group_id == group.id,
cls.author_id == author.id,
cls.voter_id == voter.id).one()
except exc.NoResultFound:
return None
# returns avg of author scores per page, language, and group
评论列表
文章目录