From 7091e15f1bd0aa8e74024ab5f256691cb036e01f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baza=CC=81n?= Date: Wed, 1 Feb 2017 17:01:09 +0100 Subject: [PATCH] separates polls in poll index based on geozone restriction --- app/views/polls/index.html.erb | 75 ++++++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 22 deletions(-) diff --git a/app/views/polls/index.html.erb b/app/views/polls/index.html.erb index 9b490f3e2..f606aaef9 100644 --- a/app/views/polls/index.html.erb +++ b/app/views/polls/index.html.erb @@ -15,30 +15,61 @@
-

<%= t("polls.index.no_geozone_restricted") %>

-

<%= t("polls.index.geozone_restricted") %>

- <% @polls.each do |poll| %> -
-
-
-
<%= poll_dates(poll) %>
-

<%= link_to poll.name, poll %>

-
    - <% poll.questions.each do |question| %> -
  • <%= link_to question.title, question_path(question) %>
  • - <% end %> -
-
    - <% poll.geozones.each do |g| %> -
  • <%= g.name %>
  • - <% end %> -
-
-
- <%= link_to t("polls.index.participate_button"), poll, class: "button" %> + <% polls_by_geozone_restriction = @polls.group_by(&:geozone_restricted) %> + + <% if polls_by_geozone_restriction[false].any? %> +

<%= t("polls.index.no_geozone_restricted") %>

+ + <% polls_by_geozone_restriction[false].each do |poll| %> +
+
+
+
<%= poll_dates(poll) %>
+

<%= link_to poll.name, poll %>

+
    + <% poll.questions.each do |question| %> +
  • <%= link_to question.title, question_path(question) %>
  • + <% end %> +
+
    + <% poll.geozones.each do |g| %> +
  • <%= g.name %>
  • + <% end %> +
+
+
+ <%= link_to t("polls.index.participate_button"), poll, class: "button" %> +
-
+ <% end %> + <% end %> + + <% if polls_by_geozone_restriction[true].any? %> +

<%= t("polls.index.geozone_restricted") %>

+ <% polls_by_geozone_restriction[true].each do |poll| %> +
+
+
+
<%= poll_dates(poll) %>
+

<%= link_to poll.name, poll %>

+
    + <% poll.questions.each do |question| %> +
  • <%= link_to question.title, question_path(question) %>
  • + <% end %> +
+
    + <% poll.geozones.each do |g| %> +
  • <%= g.name %>
  • + <% end %> +
+
+
+ <%= link_to t("polls.index.participate_button"), poll, class: "button" %> +
+
+
+ <% end %> <% end %> <%= paginate @polls %>