Up vote any "votable" object without raising an error. Vote is ignored.
166980
def up_vote!(votable)
      begin
        up_vote(votable)
        success = true
      rescue Exceptions::AlreadyVotedError
        success = false
      end
      success
    end
390381
def down_vote!(votable)
      begin
        down_vote(votable)
        success = true
      rescue Exceptions::AlreadyVotedError
        success = false
      end
      success
    end
675098
def down_vote!(voteable)
      begin
        down_vote(voteable)
        success = true
      rescue Exceptions::AlreadyVotedError
        success = false
      end
      success
    end
1005688
def choice_default_add_related_pks(self, obj):
        """"""
        if not hasattr(obj, '_voter_pks'):
            obj._voter_pks = obj.voters.values_list('pk', flat=True)
962673
def vote_count(self):
        
        return Vote.objects.filter(
            content_type=ContentType.objects.get_for_model(self),
            object_id=self.id
        ).aggregate(Sum('vote'))['vote__sum'] or 0
1053096
def form_valid(self, form):
        
        user_kwargs = (
            {'voter': self.request.user}
            if self.request.user.is_authenticated
            else {'anonymous_key': self.request.user.forum_key}
        )

        if self.object.user_changes:
            # If user changes are allowed for this poll, all the poll associated with the current
            # user must be deleted.
            TopicPollVote.objects.filter(poll_option__poll=self.object, **user_kwargs).delete()

        options = form.cleaned_data['options']
        for option in options:
            TopicPollVote.objects.create(poll_option=option, **user_kwargs)

        return HttpResponseRedirect(self.get_success_url())
723778
def votes(self, req) -> int:
        
        try:
            votes = len(self[req.key].propagates)
        except KeyError:
            votes = 0
        return votes
749129
def community_post_votes(self, post_id, **kwargs):
        ""
        api_path = "/api/v2/community/posts/{post_id}/votes.json"
        api_path = api_path.format(post_id=post_id)
        return self.call(api_path, **kwargs)
208325
def vote(cls):
        """"""
        url = configuration.VoteUrl + 'count/'
        uid = get_system_uid()
        data = {"name": cls.getName().replace('/', '_'), "uid": uid}
        page = urlopen(url, cls.session, data=data)
        return page.text
154047
def votes(ctx, account, type):
    
    if not isinstance(type, (list, tuple)):
        type = [type]
    account = Account(account, full=True)
    ret = {key: list() for key in Vote.types()}
    for vote in account["votes"]:
        t = Vote.vote_type_from_id(vote["id"])
        ret[t].append(vote)

    t = [["id", "url", "account"]]
    for vote in ret["committee"]:
        t.append(
            [vote["id"], vote["url"], Account(vote["committee_member_account"])["name"]]
        )

    if "committee" in type:
        t = [["id", "url", "account", "votes"]]
        for vote in ret["committee"]:
            t.append(
                [
                    vote["id"],
                    vote["url"],
                    Account(vote["committee_member_account"])["name"],
                    str(Amount({"amount": vote["total_votes"], "asset_id": "1.3.0"})),
                ]
            )
        print_table(t)

    if "witness" in type:
        t = [
            [
                "id",
                "account",
                "url",
                "votes",
                "last_confirmed_block_num",
                "total_missed",
                "westing",
            ]
        ]
        for vote in ret["witness"]:
            t.append(
                [
                    vote["id"],
                    Account(vote["witness_account"])["name"],
                    vote["url"],
                    str(Amount({"amount": vote["total_votes"], "asset_id": "1.3.0"})),
                    vote["last_confirmed_block_num"],
                    vote["total_missed"],
                    str(Vesting(vote.get("pay_vb")).claimable)
                    if vote.get("pay_vb")
                    else "",
                ]
            )
        print_table(t)

    if "worker" in type:
        t = [["id", "name/url", "daily_pay", "votes", "time", "account"]]
        for vote in ret["worker"]:
            votes = Amount({"amount": vote["total_votes_for"], "asset_id": "1.3.0"})
            amount = Amount({"amount": vote["daily_pay"], "asset_id": "1.3.0"})
            t.append(
                [
                    vote["id"],
                    "{name}\n{url}".format(**vote),
                    str(amount),
                    str(votes),
                    "{work_begin_date}\n-\n{work_end_date}".format(**vote),
                    str(Account(vote["worker_account"])["name"]),
                ]
            )
        print_table(t)
533507
def vote(self, identifier, weight=100.0):
        ''' 
        '''
        for num_of_retries in range(default.max_retry):
            try:
                self.steem_instance().vote(identifier, 
                    weight, self.mainaccount)
                self.msg.message("voted for " + identifier)
                time.sleep(5)
            except Exception as e:
                if re.search(r'You have already voted in a similar way', str(e)):
                    self.msg.error_message('''Already voted on 
                                        {}'''.format(identifier))
                    return "already voted"
                else:
                    self.util.retry('''COULD NOT VOTE ON 
                                    {}'''.format(identifier), 
                                    e, num_of_retries, default.wait_time)
                    self.s = None
            else:
                return True
904220
def can_vote(self, request):
        
        modelbase_obj = self.modelbase_obj

        # can't vote if liking is closed
        if modelbase_obj.likes_closed:
            return False, 'closed'
        
        # can't vote if liking is disabled
        if not modelbase_obj.likes_enabled:
            return False, 'disabled'

        # anonymous users can't vote if anonymous likes are disabled
        if not request.user.is_authenticated() and not modelbase_obj.anonymous_likes:
            return False, 'auth_required'
          
        # return false if existing votes are found
        if Vote.objects.filter(object_id=modelbase_obj.id, token=request.secretballot_token).count() == 0:
            return True, 'can_vote'
        else:
            return False, 'voted'
674599
def clean(self):
        
        super().clean()

        # At least a poster (user) or a session key must be associated with
        # the vote instance.
        if self.voter is None and self.anonymous_key is None:
            raise ValidationError(_('A user id or an anonymous key must be used.'))
        if self.voter and self.anonymous_key:
            raise ValidationError(_('A user id or an anonymous key must be used, but not both.'))
815389
def on_receive_request_vote_response(self, data):
        

        if data.get('vote_granted'):
            self.vote_count += 1

            if self.state.is_majority(self.vote_count):
                self.state.to_leader()
734651
def vote(self, upvote, id, remote_addr):
        """"""

        rv = self.db.execute(
            'SELECT likes, dislikes, voters FROM comments WHERE id=?', (id, )) \
            .fetchone()

        if rv is None:
            return None

        likes, dislikes, voters = rv
        if likes + dislikes >= 142:
            return {'likes': likes, 'dislikes': dislikes}

        bf = Bloomfilter(bytearray(voters), likes + dislikes)
        if remote_addr in bf:
            return {'likes': likes, 'dislikes': dislikes}

        bf.add(remote_addr)
        self.db.execute([
            'UPDATE comments SET',
            '    likes = likes + 1,' if upvote else 'dislikes = dislikes + 1,',
            '    voters = ?'
            'WHERE id=?;'], (buffer(bf.array), id))

        if upvote:
            return {'likes': likes + 1, 'dislikes': dislikes}
        return {'likes': likes, 'dislikes': dislikes + 1}
390125
def vote_init(vote: Vote, inputs: dict, change_address: str) -> bytes:
    ''''''

    network_params = net_query(vote.deck.network)
    deck_vote_tag_address = deck_vote_tag(vote.deck)

    tx_fee = network_params.min_tx_fee  # settle for min tx fee for now

    for utxo in inputs['utxos']:
        utxo['txid'] = unhexlify(utxo['txid'])
        utxo['scriptSig'] = unhexlify(utxo['scriptSig'])

    outputs = [
        {"redeem": 0.01, "outputScript": transactions.monosig_script(deck_vote_tag_address)},
        {"redeem": 0, "outputScript": transactions.op_return_script(vote.to_protobuf)},
        {"redeem": float(inputs['total']) - float(tx_fee) - float(0.01),
         "outputScript": transactions.monosig_script(change_address)
         }]

    return transactions.make_raw_transaction(inputs['utxos'], outputs)
1220691
def build_ajax_votes(request, user_profile):
    """"""
    vote_list = ''
    for profile in request.upvotes.all():
        vote_list += \
            '<li><a title="View Profile" href="{url}">{name}</a></li>'.format(
                url=reverse(
                    'member_profile',
                    kwargs={'targetUsername': profile.user.username}
                ),
                name='You' if profile.user == user_profile.user \
                    else profile.user.get_full_name(),
            )

    in_votes = user_profile in request.upvotes.all()
    count = request.upvotes.all().count()

    return (vote_list, in_votes, count)