models.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:annotran 作者: BirkbeckCTP 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号