diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb
index 4dce3bc81..aa93581cc 100644
--- a/app/controllers/polls_controller.rb
+++ b/app/controllers/polls_controller.rb
@@ -3,6 +3,8 @@ class PollsController < ApplicationController
load_and_authorize_resource
+ before_filter :set_poll, only: [:stats, :results]
+
has_filters %w{current expired incoming}
has_orders %w{most_voted newest oldest}, only: :show
@@ -25,11 +27,18 @@ class PollsController < ApplicationController
@commentable = @poll
@comment_tree = CommentTree.new(@commentable, params[:page], @current_order)
-
+ end
+
+ def stats
@stats = Poll::Stats.new(@poll).generate
end
def results
+ end
+
+ private
+
+ def set_poll
@poll = Poll.find(params[:poll_id])
end
diff --git a/app/models/abilities/everyone.rb b/app/models/abilities/everyone.rb
index e2529f72a..4d2fe4434 100644
--- a/app/models/abilities/everyone.rb
+++ b/app/models/abilities/everyone.rb
@@ -6,7 +6,7 @@ module Abilities
can [:read, :map], Debate
can [:read, :map, :summary, :share], Proposal
can :read, Comment
- can [:read, :results], Poll
+ can [:read, :results, :stats], Poll
can :read, Poll::Question
can [:read, :welcome], Budget
can :read, SpendingProposal
@@ -23,7 +23,6 @@ module Abilities
can [:read], Legislation::Question
can [:create], Legislation::Answer
can [:search, :comments, :read, :create, :new_comment], Legislation::Annotation
- can :read_stats, Poll
end
end
end
diff --git a/app/views/polls/_poll_header.html.erb b/app/views/polls/_poll_header.html.erb
new file mode 100644
index 000000000..db4918ab4
--- /dev/null
+++ b/app/views/polls/_poll_header.html.erb
@@ -0,0 +1,27 @@
+
+
+
+ <%= back_link_to polls_path, t("polls.show.back") %>
+
+
<%= @poll.name %>
+
+ <%= safe_html_with_links simple_format(@poll.summary) %>
+
+ <% if @poll.geozones.any? %>
+
+ <% end %>
+
+
+
+ <%= render partial: 'shared/social_share', locals: {
+ share_title: t("shared.share"),
+ title: @poll.name,
+ url: poll_url(@poll)
+ } %>
+
+
+
diff --git a/app/views/polls/_poll_subnav.html.erb b/app/views/polls/_poll_subnav.html.erb
new file mode 100644
index 000000000..9b37e1867
--- /dev/null
+++ b/app/views/polls/_poll_subnav.html.erb
@@ -0,0 +1,21 @@
+
+
+
+
+ <%= link_to t("polls.show.results_menu"),
+ poll_results_path(@poll),
+ class: (controller_name == "polls" && action_name == "results" ? "is-active" : "") %>
+
+
+ <%= link_to t("polls.show.stats_menu"),
+ poll_stats_path(@poll),
+ class: (controller_name == "polls" && action_name == "stats" ? "is-active" : "") %>
+
+
+ <%= link_to t("polls.show.info_menu"),
+ poll_path(@poll),
+ class: (controller_name == "polls" && action_name == "show" ? "is-active" : "") %>
+
+
+
+
diff --git a/app/views/polls/_results_subnavigation.html.erb b/app/views/polls/_results_subnavigation.html.erb
deleted file mode 100644
index 9c2a7e8b0..000000000
--- a/app/views/polls/_results_subnavigation.html.erb
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
- <%= link_to "#tab-stats" do %>
-
- <%= t("polls.show.stats_menu") %>
-
- <% end %>
-
-
- <%= link_to "#tab-information" do %>
-
- <%= t("polls.show.info_menu") %>
-
- <% end %>
-
-
-
-
\ No newline at end of file
diff --git a/app/views/polls/_show.html.erb b/app/views/polls/_show.html.erb
deleted file mode 100644
index ee75ea5e3..000000000
--- a/app/views/polls/_show.html.erb
+++ /dev/null
@@ -1,126 +0,0 @@
-
-
- <%= render "callout" %>
-
- <% if @poll.voted_in_booth?(current_user) %>
-
- <%= t("polls.show.already_voted_in_booth") %>
-
- <% else %>
-
- <% if current_user && @poll.voted_in_web?(current_user) %>
-
- <%= t("polls.show.already_voted_in_web") %>
-
- <% end %>
- <% end %>
-
- <% @questions.each do |question| %>
- <%= render 'polls/questions/question', question: question, token: @token %>
- <% end %>
-
- <% if poll_voter_token(@poll, current_user).empty? %>
-
- <%= t('poll_questions.show.voted_token') %>
-
- <% end %>
-
- <%= link_to t("polls.show.participate_in_other_polls"), polls_path, class: "button hollow" %>
-
-
-
-
-
-
-
<%= t("polls.show.more_info_title") %>
- <%= safe_html_with_links simple_format(@poll.description) %>
-
-
- <% if false %>
-
-
- <%= t("polls.show.documents") %>
-
- <% end %>
-
-
-
-
-
-
- <% @poll_questions_answers.each do |answer| %>
-
-
- <% if answer.description.present? %>
-
<%= answer.title %>
- <% end %>
-
- <% if answer.images.any? %>
- <%= render "gallery", answer: answer %>
- <% end %>
-
- <% if answer.description.present? %>
-
-
- <%= safe_html_with_links simple_format(answer.description) %>
-
-
-
- <% end %>
-
- <% if answer.documents.present? %>
-
-
-
- <%= t("polls.show.documents") %>
-
-
- <% answer.documents.each do |document| %>
- <%= link_to document.title,
- document.attachment.url,
- target: "_blank",
- rel: "nofollow" %>
- <% end %>
-
- <% end %>
-
- <% if answer.videos.present? %>
-
-
-
- <%= t("polls.show.videos") %>
-
-
- <% answer.videos.each do |video| %>
- <%= link_to video.title,
- video.url,
- target: "_blank",
- rel: "nofollow" %>
- <% end %>
-
- <% end %>
-
- <% end %>
-
-
-
-
-
- <%= render "filter_subnav" %>
-
-
-
\ No newline at end of file
diff --git a/app/views/polls/results.html.erb b/app/views/polls/results.html.erb
index 353f92fa1..f0c9e4a38 100644
--- a/app/views/polls/results.html.erb
+++ b/app/views/polls/results.html.erb
@@ -1,36 +1,44 @@
-