Up vote any "votable" object.
 Raises an AlreadyVotedError if the voter already voted on the object.
772785
def up_vote(votable)
      is_votable?(votable)
      
      vote = get_vote(votable)
      
      if vote
        if vote.up_vote
          raise Exceptions::AlreadyVotedError.new(true)
        else
          vote.up_vote = true
          votable.down_votes -= 1
          self.down_votes -= 1 if has_attribute?(:down_votes)
        end
      else
        vote = Vote.create(:votable => votable, :voter => self, :up_vote => true)
      end
      
      votable.up_votes += 1
      self.up_votes += 1 if has_attribute?(:up_votes)  
      
      Vote.transaction do
        save
        votable.save
        vote.save
      end
      
      true
    end
612774
ServerContext setLastVotedFor(int candidate) {
    // If we've already voted for another candidate in this term then the last voted for candidate cannot be overridden.
    Assert.stateNot(lastVotedFor != 0 && candidate != 0L, "Already voted for another candidate");
    ServerMember member = cluster.member(candidate);
    Assert.state(member != null, "unknown candidate: %d", candidate);
    this.lastVotedFor = candidate;
    meta.storeVote(this.lastVotedFor);

    if (candidate != 0) {
      LOGGER.debug("{} - Voted for {}", cluster.member().address(), member.address());
    } else {
      LOGGER.trace("{} - Reset last voted for", cluster.member().address());
    }
    return this;
  }
1126929
def unvote(voteable)
      check_voteable(voteable)

      voting = fetch_voting(voteable)

      raise Exceptions::NotVotedError unless voting

      if voting.up_vote
        voteable.up_votes -= 1
        self.up_votes -= 1 if has_attribute?(:up_votes)
      else
        voteable.down_votes -= 1
        self.down_votes -= 1 if has_attribute?(:down_votes)
      end

      Voting.transaction do
        save
        voteable.save
        voting.destroy
      end

      true
    end
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()
693843
def get_election_votes(self, election):
        """"""
        candidate_election = CandidateElection.objects.get(
            candidate=self, election=election
        )

        return candidate_election.votes.all()
856745
def has_been_completed_by(poll, user):
    
    user_votes = TopicPollVote.objects.filter(
        poll_option__poll=poll)
    if user.is_anonymous:
        forum_key = get_anonymous_user_forum_key(user)
        user_votes = user_votes.filter(anonymous_key=forum_key) if forum_key \
            else user_votes.none()
    else:
        user_votes = user_votes.filter(voter=user)
    return user_votes.exists()
6908
public function ballot($user_id = 0, $ip = null)
	{
		if (User::isGuest())
		{
			$vote = new Vote();
			$vote->set('item_type', 'comment');
			$vote->set('item_id', $this->get('id'));
			$vote->set('created_by', $user_id);
			$vote->set('ip', $ip);

			return $vote;
		}

		$user = $user_id ? User::getInstance($user_id) : User::getInstance();
		$ip   = $ip ?: Request::ip();

		// See if a person from this IP has already voted in the last week
		$votes = $this->votes();

		if ($user->get('id'))
		{
			$votes->whereEquals('created_by', $user->get('id'));
		}
		elseif ($ip)
		{
			$votes->whereEquals('ip', $ip);
		}

		$vote = $votes
			->ordered()
			->limit(1)
			->row();

		if (!$vote || !$vote->get('id'))
		{
			$vote = new Vote();
			$vote->set('item_type', 'comment');
			$vote->set('item_id', $this->get('id'));
			$vote->set('created_by', $user_id);
			if ($ip)
			{
				$vote->set('ip', $ip);
			}
		}

		return $vote;
	}
153343
def post_vote(self, post_id, score):
        
        return self._get('posts/{0}/votes.json'.format(post_id),
                         {'score': score}, 'POST', auth=True)
961384
public boolean voteDown(ParaObject obj, String voterid) {
		if (obj == null || StringUtils.isBlank(voterid)) {
			return false;
		}
		return getEntity(invokePatch(obj.getType().concat("/").concat(obj.getId()),
				Entity.json(Collections.singletonMap("_votedown", voterid))), Boolean.class);
	}
240369
def upvote
      security_transgression_unless @comment.can_be_voted_on_by?(@user)

      @comment.upvote_from @user

      respond_to do |format|
        format.html { redirect_to @thread }
        format.js { render :vote }
      end
    end
675098
def down_vote!(voteable)
      begin
        down_vote(voteable)
        success = true
      rescue Exceptions::AlreadyVotedError
        success = false
      end
      success
    end
1039591
def votes(self):
        
        votes = []
        for option in self.options.all():
            votes += option.votes.all()
        return votes
1049413
public void voteFor(WeightedItem<T> weightedItem) {
        reorganizationCounter++;
        weightedItem.vote();
        if (reorganizationCounter == maxVotesBeforeReorganization) {
            reorganizationCounter = 0;
            organizeAndAdd(null);
        }
    }
397200
private double[] getVotesForInstance(Instance instance) {
		ErrorWeightedVote errorWeightedVote=newErrorWeightedVote(); 
		int numberOfRulesCovering = 0;
		
		for (ActiveRule rule: ruleSet) {
			if (rule.isCovering(instance) == true){
				numberOfRulesCovering++;
				double [] vote=rule.getPrediction(instance);
				double error= rule.getCurrentError();
				errorWeightedVote.addVote(vote,error);
				if (!this.unorderedRules) { // Ordered Rules Option.
					break; // Only one rule cover the instance.
				}
			}
		}

		if (numberOfRulesCovering == 0) {
			double [] vote=defaultRule.getPrediction(instance);
			double error= defaultRule.getCurrentError();
			errorWeightedVote.addVote(vote,error);	
		} 	
		double[] weightedVote=errorWeightedVote.computeWeightedVote();
		
		return weightedVote;
	}
859433
def up_vote(voteable)
      check_voteable(voteable)

      voting = fetch_voting(voteable)

      if voting
        if voting.up_vote
          raise Exceptions::AlreadyVotedError.new(true)
        else
          voting.up_vote = true
          voteable.down_votes -= 1
          self.down_votes -= 1 if has_attribute?(:down_votes)
        end
      else
        voting = Voting.create(:voteable => voteable, :voter_id => self.id, :voter_type => self.class.to_s, :up_vote => true)
      end

      voteable.up_votes += 1
      self.up_votes += 1 if has_attribute?(:up_votes)

      Voting.transaction do
        save
        voteable.save
        voting.save
      end

      true
    end
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)
1334861
def get_ratings(self):
        """"""
        return Vote.objects.filter(content_type=self.get_content_type(), object_id=self.instance.pk, key=self.field.key)