コード例 #1
0
ファイル: playlist_item.py プロジェクト: cthit/playIT-python
    def _get_votes(self):
        from src.models.vote import Vote
        vote = Vote.fetch(
            fn.Sum(Vote.value).alias("value")
        ).where(Vote.item == self).first()

        return vote
コード例 #2
0
ファイル: userclient.py プロジェクト: cthit/playIT-python
    def remove_vote(cid, item):
        if "list" in item.type:
            vote = PlaylistVote.fetch().where(
                (Vote.cid == cid) &
                (Vote.item == item)
            ).first()
        else:
            vote = Vote.fetch().where(
                (Vote.cid == cid) &
                (Vote.item == item)
            ).first()

        if vote:
            vote.delete_instance()
            return True
        else:
            return False