voting

Spring-security - AccessDecisionVoter-impl wont be invoked

空扰寡人 提交于 2019-12-14 00:33:13
问题 I am trying to create custom AccessDecisionVoter and just stop it in the debugged when it gets invoked. I have put a breake point in each method, but nothing happed. spring-security.xml: <bean id="accessDecisionManager" class="org.springframework.security.access.vote.UnanimousBased"> <property name="decisionVoters"> <list> <bean class="com.affiliates.server.security.voters.VoterTest"> <property name="brandsApi" ref="brandsApi"/> </bean> </list> </property> IBrandsApi.java public interface

Rails survey style application - Show all answers on option

人走茶凉 提交于 2019-12-12 17:26:25
问题 I'm a new guy to ruby on rails and working on my first in-depth application. It has four tables: Questions , Options , Answers and Users . There's a list of questions and a user can vote for a unique option (stored in the Answers join table), I'm trying to get my head around table associations. This is how I've setup my individual RB files: class Question < ActiveRecord::Base has_many :options has_many :answers, :through => :options end class Option < ActiveRecord::Base belongs_to :question

405 error on django ajax POST

三世轮回 提交于 2019-12-12 15:05:07
问题 I have a model with a integer field wich will increment on user click, like a "vote this" button. The button only shows on the detail view. To increment the vote count it sends an ajax POST. The problem is that django returns a 405 (method not allowed) error even before executing the view. What can be causing this? Here is my code: views.py (doesn't get executed) @require_POST def vote_proposal(request, space_name): """ Increment support votes for the proposal in 1. """ prop = get_object_or

Why doesn't this Ruby on Rails code work as I intend it to?

こ雲淡風輕ζ 提交于 2019-12-12 01:57:48
问题 So I attempted to build what I asked about in this question: Fix voting mechanism However, this solution doesn't work. A user can still vote however many times he or she wants. How could I fix this and/or refactor? def create @video = Video.find(params[:video_id]) @vote = @video.video_votes.new @vote.user = current_user if params[:type] == "up" @vote.value = 1 else @vote.value = -1 end if @previous_vote.nil? if @vote.save respond_to do |format| format.html { redirect_to @video } format.js end

How to compare new string name with existing from txt file?

倾然丶 夕夏残阳落幕 提交于 2019-12-11 16:59:41
问题 I want to implement a simple function in a voting program that is searching for a name, and if this name is already existing then it will show a message that a person cannot vote. But I'm so confused with txt files. The code below does not work properly, I want to understand what I need to do. Also, how to find a full name? I think it is only searching for the first word bool searchname(string mainvoter); int main() { ofstream newvoter("voter.txt", ios::app); string name; cout<<"Enter your

Database design for questionbased voting system, has the normalization gone wrong?

心已入冬 提交于 2019-12-11 10:06:47
问题 I need to create a database system wherein normal users can create questions with, only 2, belonging answers and these questions can then get a up- or down-vote by people visiting the site. I am wondering in which way it would be best to create this database, specifically the tables required and their relations. Within this site, there will be, at least, two user groups . Normal users and institution users . Institution users should be able to create a profile for their institution , normal

AJAX + PHP voting system

一世执手 提交于 2019-12-11 06:15:32
问题 I'm working on a voting system in AJAX and PHP and I've run into a bit of trouble. We're displaying a bunch of posts from our database and each post has an image next to it -- clicking the image is supposed to 1) toggle the image colour and then 2) use AJAX call a PHP script which then decides whether to add or subtract a vote. I have the image toggle working, but I'm not sure how to do the next part. What's the best way to do this? This is the while-loop which outputs the posts: while($row =

RoR voting system. Counting votes by condition vote = true or vote = false not working

社会主义新天地 提交于 2019-12-08 09:41:41
问题 I have these models Issue Vote Issue has_many votes and Vote belongs_to issue. The Vote model has a boolean vote attribute. On the issues index view I want to cycle through the issues and display the title, body, an up vote button, a down vote button, and respective labels that show how many up votes and down votes there currently is. I do this with a form with hidden fields for issue_id and vote (1 or 0). Methods on the Issue model are supposed to count the votes. But I keep getting 0

Drupal Creating Votes in Voting API Through Code

為{幸葍}努か 提交于 2019-12-06 07:13:49
问题 I have a custom module I'm writing, part of what I want it to do is create a vote associated with a node, I'm trying to figure out how to call the voting API from my module. I loookd in the documentation but it's a little sparse. 回答1: Here is an example from a module I wrote a while ago. while ($data = db_fetch_object($result)) { $node = node_load($data->nid); $node_terms = taxonomy_node_get_terms($node); $vote['value'] = 0; $vote['value_type'] = 'points'; foreach ($node_terms as $term) {

Spring-security - AccessDecisionVoter-impl wont be invoked

喜你入骨 提交于 2019-12-05 13:18:21
I am trying to create custom AccessDecisionVoter and just stop it in the debugged when it gets invoked. I have put a breake point in each method, but nothing happed. spring-security.xml: <bean id="accessDecisionManager" class="org.springframework.security.access.vote.UnanimousBased"> <property name="decisionVoters"> <list> <bean class="com.affiliates.server.security.voters.VoterTest"> <property name="brandsApi" ref="brandsApi"/> </bean> </list> </property> IBrandsApi.java public interface IBrandsApi { IHibernateBean getByPK(Integer id); @Secured({ "ROLE_BRAND_ADMIN" }) IHibernateBean update