Show a poll. We send informations about votes only if the user is an administrator
359929
def show(request, pollId):
    """"""

    # Get the poll
    curDB.execute('SELECT id, title, description FROM Poll WHERE id = ? ORDER BY title', (pollId,))
    poll = curDB.fetchone()

    if poll is None:
        return {}

    responses = []
    totalVotes = 0
    votedFor = 0

    # Compute the list of responses
    curDB.execute('SELECT id, title FROM Response WHERE pollId = ? ORDER BY title ', (poll[0],))
    resps = curDB.fetchall()

    for rowRep in resps:

        votes = []
        nbVotes = 0

        # List each votes
        for rowVote in curDB.execute('SELECT username FROM Vote WHERE responseId = ?', (rowRep[0],)):

            nbVotes += 1

            # If the user is and administrator, saves each votes
            if request.args.get('ebuio_u_ebuio_admin') == 'True':
                votes.append(rowVote[0])

            # Save the vote of the current suer
            if request.args.get('ebuio_u_username') == rowVote[0]:
                votedFor = rowRep[0]

        totalVotes += nbVotes
        responses.append({'id': rowRep[0], 'title': rowRep[1], 'nbVotes': nbVotes, 'votes': votes})

    return {'id': poll[0], 'name': poll[1], 'description': poll[2], 'responses': responses, 'totalVotes': totalVotes, 'votedFor': votedFor}
792499
def downvote(self):
        
        data = self.get_selected_item()
        if 'likes' not in data:
            self.term.flash()
        elif getattr(data['object'], 'archived'):
            self.term.show_notification("Voting disabled for archived post", style='Error')
        elif data['likes'] or data['likes'] is None:
            with self.term.loader('Voting'):
                data['object'].downvote()
            if not self.term.loader.exception:
                data['likes'] = False
        else:
            with self.term.loader('Clearing vote'):
                data['object'].clear_vote()
            if not self.term.loader.exception:
                data['likes'] = None
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
1047192
def perform_permissions_check(self, user, obj, perms):
        
        return self.request.forum_permission_handler.can_update_topics_to_sticky_topics(obj, user)
1233309
def is_admin(self):
        
        for ur in self.roleusers:
            if ur.role.code == 'admin':
                return True

        return False
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()
626662
def check_user_can_send_comments(user_info, recid):
    
    # First can we find an authorization for this case, action + collection
    record_primary_collection = guess_primary_collection_of_a_record(recid)
    return acc_authorize_action(
        user_info,
        'sendcomment',
        authorized_if_no_roles=True,
        collection=record_primary_collection)
1222138
def user_is_admin?(user)
      Array(robot.config.robot.admins).include?(user.id)
    end
552587
def unvote
      security_transgression_unless @comment.can_be_voted_on_by?(@user)

      @comment.unvote voter: @user

      respond_to do |format|
        format.html { redirect_to @thread }
        format.js { render :vote }
      end
    end
964389
public function deletePoll(Poll $poll): bool
    {
        if (empty($poll->getAdminKey())) {
            throw new \Exception(sprintf('Admin key not available. Poll %s cannot be deleted.', $poll->getId()), 1443782170);
        }
        return $this->doDelete('/api/v2.0/polls/' . $poll->getId() . '?adminKey=' . $poll->getAdminKey());
    }
1330483
def help_center_user_votes(self, user_id, **kwargs):
        ""
        api_path = "/api/v2/help_center/users/{user_id}/votes.json"
        api_path = api_path.format(user_id=user_id)
        return self.call(api_path, **kwargs)
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;
	}
1296829
def up_voted?(votable)
      is_votable?(votable)
      vote = get_vote(votable)
      return false if vote.nil?
      return true if vote.has_attribute?(:up_vote) && vote.up_vote
      false
    end
773544
def poll(self):
        
        response = self.client.protocol.get('/uploads/{upload_id}',
                                            upload_id=self.upload_id,
                                            check_for_errors=False)

        self.update_from_response(response)
454356
def tally_poll(args):
    """"""
    if not args.msg:
        return "Syntax: !vote tally <pollnum>"
    if not args.msg.isdigit():
        return "Not A Valid Positive Integer."
    pid = int(args.msg)
    poll = get_open_poll(args.session, pid)
    if poll is None:
        return "That poll doesn't exist or was deleted. Use !poll list to see valid polls"
    state = "Active" if poll.active == 1 else "Closed"
    votes = args.session.query(Poll_responses).filter(Poll_responses.pid == pid).all()
    args.send("%s poll: %s, %d total votes" % (state, poll.question, len(votes)))
    votemap = collections.defaultdict(list)
    for v in votes:
        votemap[v.response].append(v.voter)
    for x in sorted(votemap.keys()):
        args.send("%s: %d -- %s" % (x, len(votemap[x]), ", ".join(votemap[x])), target=args.nick)
    if not votemap:
        return ""
    ranking = collections.defaultdict(list)
    for x in votemap.keys():
        num = len(votemap[x])
        ranking[num].append(x)
    high = max(ranking)
    winners = (ranking[high], high)
    if len(winners[0]) == 1:
        winners = (winners[0][0], high)
        return "The winner is %s with %d votes." % winners
    else:
        winners = (", ".join(winners[0]), high)
        return "Tie between %s with %d votes." % winners
1166927
def perform_permissions_check(self, user, obj, perms):
        
        return self.request.forum_permission_handler.can_add_post(obj, user)
1060360
void polling_configure() {
	// Send a stop polling command to thread in order not to poll devices
	final DServer adm_dev = get_dserver_device();

	try {
	    adm_dev.stop_polling();
	} catch (final DevFailed e) {
	    Except.print_exception(e);
	}

	final Vector tmp_cl_list = adm_dev.get_class_list();// DeviceClass
	int upd;

	// Create the structure used to send data to the polling thread
	final DevVarLongStringArray send = new DevVarLongStringArray();
	send.lvalue = new int[1];
	send.svalue = new String[3];

	// A loop on each class and each device in class
	for (int i = 0; i < tmp_cl_list.size(); i++) {
	    final DeviceClass dc = (DeviceClass) tmp_cl_list.elementAt(i);
	    final Vector dev_list = dc.get_device_list(); // <DeviceImpl *
	    for (int j = 0; j < dev_list.size(); j++) {
		final DeviceImpl dev = (DeviceImpl) dev_list.elementAt(j);
		final Vector poll_cmd_list = dev.get_polled_cmd();
		final Vector poll_attr_list = dev.get_polled_attr();

		// Send a Add Object command to the polling thread only
		// if the polling period is different than zero
		for (int k = 0; k < poll_cmd_list.size(); k++) {
		    if (k == 0) {
			send.svalue[0] = dev.get_name();
			send.svalue[1] = "command";
		    }

		    // Convert polling period to a number
		    final String strval = (String) poll_cmd_list.elementAt(k + 1);
		    upd = Integer.parseInt(strval);

		    // Send command to the polling thread
		    if (upd != 0) {
			send.lvalue[0] = upd;
			send.svalue[2] = (String) poll_cmd_list.elementAt(k);

			try {
			    adm_dev.add_obj_polling(send, false);
			} catch (final DevFailed e) {
			}
		    }
		    k++;
		}

		// Send a Add Object attribute to the polling thread only
		// if the polling period is different than zero
		for (int k = 0; k < poll_attr_list.size(); k++) {

		    if (k == 0) {
			send.svalue[0] = dev.get_name();
			send.svalue[1] = "attribute";
		    }
		    // Convert polling period to a number
		    final String strval = (String) poll_attr_list.elementAt(k + 1);
		    upd = Integer.parseInt(strval);

		    // Send command to the polling thread
		    if (upd != 0) {
			send.lvalue[0] = upd;
			send.svalue[2] = (String) poll_attr_list.elementAt(k);

			try {
			    adm_dev.add_obj_polling(send, false);
			} catch (final DevFailed e) {
			}
		    }
		    k++;
		}
	    }
	}

	// Now, start the real polling
	try {
	    adm_dev.start_polling();
	} catch (final DevFailed e) {
	    Except.print_exception(e);
	}
    }