Merge pull request #1993 from consul/1984-voting_messages
Voting messages
This commit is contained in:
@@ -41,4 +41,8 @@ module PollsHelper
|
|||||||
booth.name + location
|
booth.name + location
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def voted_before_sign_in(question)
|
||||||
|
current_user.current_sign_in_at >= question.answers.find_or_initialize_by(author: current_user).updated_at
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<div class="poll-question-answers">
|
<div class="poll-question-answers">
|
||||||
<% if can? :answer, question %>
|
<% if can? :answer, question %>
|
||||||
<% question.question_answers.each do |answer| %>
|
<% question.question_answers.each do |answer| %>
|
||||||
<% if @answers_by_question_id[question.id] == answer.title %>
|
<% if @answers_by_question_id[question.id] == answer.title && !voted_before_sign_in(question) %>
|
||||||
<span class="button answered"
|
<span class="button answered"
|
||||||
title="<%= t("poll_questions.show.voted", answer: answer)%>">
|
title="<%= t("poll_questions.show.voted", answer: answer.title)%>">
|
||||||
<%= answer.title %>
|
<%= answer.title %>
|
||||||
</span>
|
</span>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
|||||||
@@ -38,6 +38,11 @@
|
|||||||
<%= t("polls.show.already_voted_in_booth") %>
|
<%= t("polls.show.already_voted_in_booth") %>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
<% if current_user && !@poll.votable_by?(current_user) %>
|
||||||
|
<div class="callout warning">
|
||||||
|
<%= t("polls.show.already_voted_in_web") %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
<% @questions.each do |question| %>
|
<% @questions.each do |question| %>
|
||||||
<%= render 'polls/questions/question', question: question %>
|
<%= render 'polls/questions/question', question: question %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -478,7 +478,8 @@ en:
|
|||||||
help_text_1: "Voting takes place when a citizen proposal supports reaches 1% of the census with voting rights. Voting can also include questions that the City Council ask to the citizens decision."
|
help_text_1: "Voting takes place when a citizen proposal supports reaches 1% of the census with voting rights. Voting can also include questions that the City Council ask to the citizens decision."
|
||||||
help_text_2: "To participate in the next vote you have to sign up on %{org} and verify your account. All registered voters in the city over 16 years old can vote. The results of all votes are binding on the government."
|
help_text_2: "To participate in the next vote you have to sign up on %{org} and verify your account. All registered voters in the city over 16 years old can vote. The results of all votes are binding on the government."
|
||||||
show:
|
show:
|
||||||
already_voted_in_booth: "You have already participated in a booth for this poll."
|
already_voted_in_booth: "You have already participated in a physical booth. You can not participate again."
|
||||||
|
already_voted_in_web: "You have already participated in this poll. If you vote again it will be overwritten."
|
||||||
back: Back to voting
|
back: Back to voting
|
||||||
cant_answer_not_logged_in: "You must %{signin} or %{signup} to participate."
|
cant_answer_not_logged_in: "You must %{signin} or %{signup} to participate."
|
||||||
signin: Sign in
|
signin: Sign in
|
||||||
|
|||||||
@@ -478,7 +478,8 @@ es:
|
|||||||
help_text_1: "Las votaciones se convocan cuando una propuesta ciudadana alcanza el 1% de apoyos del censo con derecho a voto. En las votaciones también se pueden incluir cuestiones que el Ayuntamiento somete a decisión directa de la ciudadanía."
|
help_text_1: "Las votaciones se convocan cuando una propuesta ciudadana alcanza el 1% de apoyos del censo con derecho a voto. En las votaciones también se pueden incluir cuestiones que el Ayuntamiento somete a decisión directa de la ciudadanía."
|
||||||
help_text_2: "Para participar en la próxima votación tienes que registrarte en %{org} y verificar tu cuenta. Pueden votar todas las personas empadronadas en la ciudad mayores de 16 años. Los resultados de todas las votaciones serán vinculantes para el gobierno."
|
help_text_2: "Para participar en la próxima votación tienes que registrarte en %{org} y verificar tu cuenta. Pueden votar todas las personas empadronadas en la ciudad mayores de 16 años. Los resultados de todas las votaciones serán vinculantes para el gobierno."
|
||||||
show:
|
show:
|
||||||
already_voted_in_booth: "Ya has participado en esta votación en una urna."
|
already_voted_in_booth: "Ya has participado en esta votación en urnas presenciales, no puedes volver a participar."
|
||||||
|
already_voted_in_web: "Ya has participado en esta votación. Si vuelves a votar se sobreescribirá tu resultado anterior."
|
||||||
back: Volver a votaciones
|
back: Volver a votaciones
|
||||||
cant_answer_not_logged_in: "Necesitas %{signin} o %{signup} para participar."
|
cant_answer_not_logged_in: "Necesitas %{signin} o %{signup} para participar."
|
||||||
signin: iniciar sesión
|
signin: iniciar sesión
|
||||||
|
|||||||
@@ -209,8 +209,7 @@ feature 'Polls' do
|
|||||||
visit poll_path(poll)
|
visit poll_path(poll)
|
||||||
|
|
||||||
expect(page).to have_link('Han Solo')
|
expect(page).to have_link('Han Solo')
|
||||||
expect(page).to_not have_link('Chewbacca')
|
expect(page).to have_link('Chewbacca')
|
||||||
expect(page).to have_content('Chewbacca')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Level 2 users answering', :js do
|
scenario 'Level 2 users answering', :js do
|
||||||
|
|||||||
@@ -91,9 +91,32 @@ feature "Voter" do
|
|||||||
visit poll_path(poll)
|
visit poll_path(poll)
|
||||||
|
|
||||||
expect(page).to_not have_link('Yes')
|
expect(page).to_not have_link('Yes')
|
||||||
expect(page).to have_content "You have already participated in a booth for this poll."
|
expect(page).to have_content "You have already participated in a physical booth. You can not participate again."
|
||||||
expect(Poll::Voter.count).to eq(1)
|
expect(Poll::Voter.count).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario "Trying to vote in web again", :js do
|
||||||
|
login_as user
|
||||||
|
vote_for_poll_via_web(poll, question)
|
||||||
|
|
||||||
|
visit poll_path(poll)
|
||||||
|
|
||||||
|
expect(page).to have_content "You have already participated in this poll. If you vote again it will be overwritten."
|
||||||
|
within("#poll_question_#{question.id}_answers") do
|
||||||
|
expect(page).to_not have_link('Yes')
|
||||||
|
end
|
||||||
|
|
||||||
|
click_link "Sign out"
|
||||||
|
|
||||||
|
login_as user
|
||||||
|
visit poll_path(poll)
|
||||||
|
|
||||||
|
within("#poll_question_#{question.id}_answers") do
|
||||||
|
expect(page).to have_link('Yes')
|
||||||
|
expect(page).to have_link('No')
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user