diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb
index 7433ea95b..28ce9c447 100644
--- a/app/controllers/polls_controller.rb
+++ b/app/controllers/polls_controller.rb
@@ -9,7 +9,10 @@ class PollsController < ApplicationController
end
def show
- @questions = @poll.questions.sort_for_list.for_render
+ questions = @poll.questions.sort_for_list.for_render
+
+ @answerable_questions = questions.answerable_by(current_user)
+ @non_answerable_questions = questions.where.not(id: @answerable_questions.pluck(:id))
end
end
diff --git a/app/views/polls/_warnings.html.erb b/app/views/polls/_warnings.html.erb
deleted file mode 100644
index b6b44fbc0..000000000
--- a/app/views/polls/_warnings.html.erb
+++ /dev/null
@@ -1,28 +0,0 @@
-<% if current_user.nil? %>
-
-
- <%= t("polls.show.cant_answer_not_logged_in",
- signin: link_to(t("polls.show.signin"), new_user_session_path, class: "probe-message"),
- signup: link_to(t("polls.show.signup"), new_user_registration_path, class: "probe-message")).html_safe %>
-
-
-<% elsif current_user.unverified? %>
-
- <%= question.title %>
-
- <%= question.valid_answers.each do |valid_answer| %>
- <% if can? :answer, @poll %>
- <%= link_to valid_answer %>
- <% else %>
-
<%= valid_answer %>
- <% end %>
- <% end %>
-
- <% if false #wrong geozone %>
+<% unless can?(:answer, @poll) %>
+
+ <% if current_user.nil? %>
+
+ <%= t("polls.show.cant_answer_not_logged_in",
+ signin: link_to(t("polls.show.signin"), new_user_session_path, class: "probe-message"),
+ signup: link_to(t("polls.show.signup"), new_user_registration_path, class: "probe-message")).html_safe %>
+
+ <% elsif current_user.unverified? %>
- <%= t('polls.show.cant_answer_wrong_geozone') %>
+ <%= t('polls.show.cant_answer_verify_html',
+ verify_link: link_to(t('polls.show.verify_link'), verification_path)) %>
+
+ <% elsif @poll.incoming? %>
+
+ <%= t('polls.show.cant_answer_incoming') %>
+
+ <% elsif @poll.expired? %>
+
+ <%= t('polls.show.cant_answer_expired') %>
<% end %>
<% end %>
+
+<% @answerable_questions.each do |question| %>
+
+ <%= question.title %>
+
+ <% question.valid_answers.each do |valid_answer| %>
+ <%= link_to valid_answer %>
+ <% end %>
+
+<% end %>
+
+<% if can?(:answer, @poll) &&
+ @non_answerable_questions.present? %>
+
+ <%= t('polls.show.cant_answer_wrong_geozone') %>
+
+<% end %>
+
+<% @non_answerable_questions.each do |question| %>
+
+ <%= question.title %>
+
+ <% question.valid_answers.each do |valid_answer| %>
+ <%= valid_answer %>
+ <% end %>
+
+<% end %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index d139b724b..b032b5805 100755
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -384,7 +384,7 @@ en:
verify_link: "verify your account"
cant_answer_incoming: "This poll has not yet started."
cant_answer_expired: "This poll has finished."
- cant_answer_wrong_geozone: "This enquiry is not available on your geozone."
+ cant_answer_wrong_geozone: "The following questions are not available in your geozone."
proposal_ballots:
title: "Votings"
description_html: "The following citizen proposals that have reached the
required supports and will be voted."
diff --git a/spec/features/polls_spec.rb b/spec/features/polls_spec.rb
index 4ef146f72..a0da259aa 100644
--- a/spec/features/polls_spec.rb
+++ b/spec/features/polls_spec.rb
@@ -86,9 +86,10 @@ feature 'Polls' do
login_as(create(:user, geozone: geozone))
visit poll_path(poll)
+ expect(page).to have_content('You must verify your account in order to answer')
+
expect(page).to have_content('Han Solo')
expect(page).to have_content('Chewbacca')
- expect(page).to have_content('You must verify your account in order to answer')
expect(page).to_not have_link('Han Solo')
expect(page).to_not have_link('Chewbacca')
@@ -124,12 +125,14 @@ feature 'Polls' do
expect(page).to have_content('This poll has finished')
end
- xscenario 'Level 2 users in an question for a geozone which is not theirs' do
+ scenario 'Level 2 users in a poll with questions for a geozone which is not theirs' do
create(:poll_question, poll: poll, geozone_ids: [], valid_answers: 'Vader, Palpatine')
login_as(create(:user, :level_two))
visit poll_path(poll)
+ expect(page).to have_content('The following questions are not available in your geozone')
+
expect(page).to have_content('Vader')
expect(page).to have_content('Palpatine')
expect(page).to_not have_link('Vader')