Merge pull request #1994 from consul/feature/1985#voting_token

Voter Answer unique Token
This commit is contained in:
Raimond Garcia
2017-10-07 16:54:01 +02:00
committed by GitHub
17 changed files with 79 additions and 17 deletions

View File

@@ -7,11 +7,12 @@ class Polls::QuestionsController < ApplicationController
def answer
answer = @question.answers.find_or_initialize_by(author: current_user)
token = params[:token]
answer.answer = params[:answer]
answer.touch if answer.persisted?
answer.save!
answer.record_voter_participation
answer.record_voter_participation(token)
@answers_by_question_id = { @question.id => params[:answer] }
end

View File

@@ -1,5 +1,7 @@
class PollsController < ApplicationController
include PollsHelper
load_and_authorize_resource
has_filters %w{current expired incoming}
@@ -12,7 +14,7 @@ class PollsController < ApplicationController
def show
@questions = @poll.questions.for_render.sort_for_list
@token = poll_voter_token(@poll, current_user)
@answers_by_question_id = {}
poll_answers = ::Poll::Answer.by_question(@poll.question_ids).by_author(current_user.try(:id))
poll_answers.each do |answer|