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
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