Poll views improvements
Reorganized poll `#show`, `#stats` and `#results` views. Gave stats section its own route.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
27
app/views/polls/_poll_header.html.erb
Normal file
27
app/views/polls/_poll_header.html.erb
Normal file
@@ -0,0 +1,27 @@
|
||||
<div class="expanded no-margin-top polls-show-header">
|
||||
<div class="row">
|
||||
<div class="small-12 medium-9 column padding">
|
||||
<%= back_link_to polls_path, t("polls.show.back") %>
|
||||
|
||||
<h2><%= @poll.name %></h2>
|
||||
|
||||
<%= safe_html_with_links simple_format(@poll.summary) %>
|
||||
|
||||
<% if @poll.geozones.any? %>
|
||||
<ul class="no-bullet margin-top tags">
|
||||
<% @poll.geozones.each do |g| %>
|
||||
<li class="inline-block"><span><%= g.name %></span></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<aside class="small-12 medium-3 column margin-top">
|
||||
<%= render partial: 'shared/social_share', locals: {
|
||||
share_title: t("shared.share"),
|
||||
title: @poll.name,
|
||||
url: poll_url(@poll)
|
||||
} %>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
21
app/views/polls/_poll_subnav.html.erb
Normal file
21
app/views/polls/_poll_subnav.html.erb
Normal file
@@ -0,0 +1,21 @@
|
||||
<div class="row">
|
||||
<div class="small-12 column">
|
||||
<ul class="tabs">
|
||||
<li class="tabs-title">
|
||||
<%= link_to t("polls.show.results_menu"),
|
||||
poll_results_path(@poll),
|
||||
class: (controller_name == "polls" && action_name == "results" ? "is-active" : "") %>
|
||||
</li>
|
||||
<li class="tabs-title">
|
||||
<%= link_to t("polls.show.stats_menu"),
|
||||
poll_stats_path(@poll),
|
||||
class: (controller_name == "polls" && action_name == "stats" ? "is-active" : "") %>
|
||||
</li>
|
||||
<li class="tabs-title is-active">
|
||||
<%= link_to t("polls.show.info_menu"),
|
||||
poll_path(@poll),
|
||||
class: (controller_name == "polls" && action_name == "show" ? "is-active" : "") %>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,20 +0,0 @@
|
||||
<div class="row">
|
||||
<div class="small-12 column">
|
||||
<ul class="tabs" data-tabs id="polls-tabs">
|
||||
<li class="tabs-title">
|
||||
<%= link_to "#tab-stats" do %>
|
||||
<h3>
|
||||
<%= t("polls.show.stats_menu") %> <!-- t("polls.show.comments_tab") -->
|
||||
</h3>
|
||||
<% end %>
|
||||
</li>
|
||||
<li class="tabs-title is-active">
|
||||
<%= link_to "#tab-information" do %>
|
||||
<h3>
|
||||
<%= t("polls.show.info_menu") %>
|
||||
</h3>
|
||||
<% end %>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,126 +0,0 @@
|
||||
<div class="row margin">
|
||||
<div class="small-12 medium-9 column">
|
||||
<%= render "callout" %>
|
||||
|
||||
<% if @poll.voted_in_booth?(current_user) %>
|
||||
<div class="callout warning">
|
||||
<%= t("polls.show.already_voted_in_booth") %>
|
||||
</div>
|
||||
<% else %>
|
||||
|
||||
<% if current_user && @poll.voted_in_web?(current_user) %>
|
||||
<div class="callout warning">
|
||||
<%= t("polls.show.already_voted_in_web") %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% @questions.each do |question| %>
|
||||
<%= render 'polls/questions/question', question: question, token: @token %>
|
||||
<% end %>
|
||||
|
||||
<% if poll_voter_token(@poll, current_user).empty? %>
|
||||
<div class="callout token-message js-token-message" style="display: none">
|
||||
<%= t('poll_questions.show.voted_token') %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= link_to t("polls.show.participate_in_other_polls"), polls_path, class: "button hollow" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="expanded poll-more-info">
|
||||
<div class="row margin">
|
||||
<div class="small-12 medium-9 column">
|
||||
<h3><%= t("polls.show.more_info_title") %></h3>
|
||||
<%= safe_html_with_links simple_format(@poll.description) %>
|
||||
</div>
|
||||
|
||||
<% if false %>
|
||||
<aside class="small-12 medium-3 column">
|
||||
<div class="sidebar-divider"></div>
|
||||
<h2><%= t("polls.show.documents") %></h2>
|
||||
</aside>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="expanded poll-more-info-answers">
|
||||
<div class="row padding">
|
||||
|
||||
<% @poll_questions_answers.each do |answer| %>
|
||||
<div class="small-12 medium-6 column end answer <%= cycle('first', '') %>" id="answer_<%= answer.id %>">
|
||||
|
||||
<% if answer.description.present? %>
|
||||
<h3><%= answer.title %></h3>
|
||||
<% end %>
|
||||
|
||||
<% if answer.images.any? %>
|
||||
<%= render "gallery", answer: answer %>
|
||||
<% end %>
|
||||
|
||||
<% if answer.description.present? %>
|
||||
<div class="margin-top">
|
||||
<div id="answer_description_<%= answer.id %>" class="answer-description short" data-toggler="short">
|
||||
<%= safe_html_with_links simple_format(answer.description) %>
|
||||
</div>
|
||||
<div class="margin">
|
||||
<a id="read_more_<%= answer.id %>"
|
||||
data-toggle="answer_description_<%= answer.id %> read_more_<%= answer.id %> read_less_<%= answer.id %>"
|
||||
data-toggler="hide">
|
||||
<%= t("polls.show.read_more", answer: answer.title) %>
|
||||
</a>
|
||||
<a id="read_less_<%= answer.id %>"
|
||||
data-toggle="answer_description_<%= answer.id %> read_more_<%= answer.id %> read_less_<%= answer.id %>"
|
||||
data-toggler="hide"
|
||||
class="hide">
|
||||
<%= t("polls.show.read_less", answer: answer.title) %>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if answer.documents.present? %>
|
||||
<div class="document-link">
|
||||
<p>
|
||||
<span class="icon-document"></span>
|
||||
<strong><%= t("polls.show.documents") %></strong>
|
||||
</p>
|
||||
|
||||
<% answer.documents.each do |document| %>
|
||||
<%= link_to document.title,
|
||||
document.attachment.url,
|
||||
target: "_blank",
|
||||
rel: "nofollow" %><br>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if answer.videos.present? %>
|
||||
<div class="video-link">
|
||||
<p>
|
||||
<span class="icon-video"></span>
|
||||
<strong><%= t("polls.show.videos") %></strong>
|
||||
</p>
|
||||
|
||||
<% answer.videos.each do |video| %>
|
||||
<%= link_to video.title,
|
||||
video.url,
|
||||
target: "_blank",
|
||||
rel: "nofollow" %><br>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="tabs-content" data-tabs-content="proposals-tabs" role="tablist">
|
||||
<%= render "filter_subnav" %>
|
||||
|
||||
<div class="tabs-panel is-active" id="tab-comments">
|
||||
<%= render "comments" %>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,36 +1,44 @@
|
||||
<div class="row">
|
||||
<div class="small-12 medium-3 column sidebar">
|
||||
<h4>Preguntas</h4>
|
||||
<ul class="menu vertical">
|
||||
<% provide :title do %><%= @poll.name %><% end %>
|
||||
|
||||
<div class="polls-show">
|
||||
<%= render "poll_header" %>
|
||||
|
||||
<%= render "poll_subnav" %>
|
||||
|
||||
<div class="row margin">
|
||||
<div class="small-12 medium-3 column sidebar">
|
||||
<h4>Preguntas</h4>
|
||||
<ul class="menu vertical">
|
||||
<%- @poll.questions.each do |question| %>
|
||||
<li><%=link_to question.title, "##{question.title.parameterize}" %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-9 column">
|
||||
<%- @poll.questions.each do |question| %>
|
||||
<li><%=link_to question.title, "##{question.title.parameterize}" %></li>
|
||||
<table>
|
||||
<h3 anchor="<%= question.title.parameterize %>"><%= question.title %></h3>
|
||||
<thead>
|
||||
<tr>
|
||||
<%- question.question_answers.each do |answer| %>
|
||||
<th scope="col" <%= answer.is_winner? ? "class=win" : "" %>><%= answer.title %></th>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<%- question.question_answers.each do |answer| %>
|
||||
<td <%= answer.is_winner? ? "class=win" : "" %>>
|
||||
<%= answer.total_votes %>
|
||||
(<%= answer.total_votes_percentage %>%)
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-9 column">
|
||||
<%- @poll.questions.each do |question| %>
|
||||
<table>
|
||||
<h3 anchor="<%= question.title.parameterize %>"><%= question.title %></h3>
|
||||
<thead>
|
||||
<tr>
|
||||
<%- question.question_answers.each do |answer| %>
|
||||
<th scope="col" <%= answer.is_winner? ? "class=win" : "" %>><%= answer.title %></th>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<%- question.question_answers.each do |answer| %>
|
||||
<td <%= answer.is_winner? ? "class=win" : "" %>>
|
||||
<%= answer.total_votes %>
|
||||
(<%= answer.total_votes_percentage %>%)
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,44 +1,134 @@
|
||||
<% provide :title do %><%= @poll.name %><% end %>
|
||||
|
||||
<div class="polls-show">
|
||||
<div class="expanded no-margin-top polls-show-header">
|
||||
<div class="row">
|
||||
<div class="small-12 medium-9 column padding">
|
||||
<%= back_link_to polls_path, t("polls.show.back") %>
|
||||
<%= render "poll_header" %>
|
||||
|
||||
<h2><%= @poll.name %></h2>
|
||||
<%= render "poll_subnav" %>
|
||||
|
||||
<%= safe_html_with_links simple_format(@poll.summary) %>
|
||||
<div class="row margin">
|
||||
<div class="small-12 medium-9 column">
|
||||
<%= render "callout" %>
|
||||
|
||||
<% if @poll.geozones.any? %>
|
||||
<ul class="no-bullet margin-top tags">
|
||||
<% @poll.geozones.each do |g| %>
|
||||
<li class="inline-block"><span><%= g.name %></span></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% if @poll.voted_in_booth?(current_user) %>
|
||||
<div class="callout warning">
|
||||
<%= t("polls.show.already_voted_in_booth") %>
|
||||
</div>
|
||||
<% else %>
|
||||
|
||||
<% if current_user && @poll.voted_in_web?(current_user) %>
|
||||
<div class="callout warning">
|
||||
<%= t("polls.show.already_voted_in_web") %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<aside class="small-12 medium-3 column margin-top">
|
||||
<%= render partial: 'shared/social_share', locals: {
|
||||
share_title: t("shared.share"),
|
||||
title: @poll.name,
|
||||
url: poll_url
|
||||
} %>
|
||||
</aside>
|
||||
<% @questions.each do |question| %>
|
||||
<%= render 'polls/questions/question', question: question, token: @token %>
|
||||
<% end %>
|
||||
|
||||
<% if poll_voter_token(@poll, current_user).empty? %>
|
||||
<div class="callout token-message js-token-message" style="display: none">
|
||||
<%= t('poll_questions.show.voted_token') %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= link_to t("polls.show.participate_in_other_polls"), polls_path, class: "button hollow" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tabs-content" data-tabs-content="polls-tabs" role="tablist">
|
||||
<%= render "results_subnavigation" %>
|
||||
<div class="expanded poll-more-info">
|
||||
<div class="row margin">
|
||||
<div class="small-12 medium-9 column">
|
||||
<h3><%= t("polls.show.more_info_title") %></h3>
|
||||
<%= safe_html_with_links simple_format(@poll.description) %>
|
||||
</div>
|
||||
|
||||
<div id="tab-stats" class="tabs-panel">
|
||||
<%= render "polls/stats/show" %>
|
||||
<% if false %>
|
||||
<aside class="small-12 medium-3 column">
|
||||
<div class="sidebar-divider"></div>
|
||||
<h2><%= t("polls.show.documents") %></h2>
|
||||
</aside>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="expanded poll-more-info-answers">
|
||||
<div class="row padding">
|
||||
|
||||
<% @poll_questions_answers.each do |answer| %>
|
||||
<div class="small-12 medium-6 column end answer <%= cycle('first', '') %>" id="answer_<%= answer.id %>">
|
||||
|
||||
<% if answer.description.present? %>
|
||||
<h3><%= answer.title %></h3>
|
||||
<% end %>
|
||||
|
||||
<% if answer.images.any? %>
|
||||
<%= render "gallery", answer: answer %>
|
||||
<% end %>
|
||||
|
||||
<% if answer.description.present? %>
|
||||
<div class="margin-top">
|
||||
<div id="answer_description_<%= answer.id %>" class="answer-description short" data-toggler="short">
|
||||
<%= safe_html_with_links simple_format(answer.description) %>
|
||||
</div>
|
||||
<div class="margin">
|
||||
<a id="read_more_<%= answer.id %>"
|
||||
data-toggle="answer_description_<%= answer.id %> read_more_<%= answer.id %> read_less_<%= answer.id %>"
|
||||
data-toggler="hide">
|
||||
<%= t("polls.show.read_more", answer: answer.title) %>
|
||||
</a>
|
||||
<a id="read_less_<%= answer.id %>"
|
||||
data-toggle="answer_description_<%= answer.id %> read_more_<%= answer.id %> read_less_<%= answer.id %>"
|
||||
data-toggler="hide"
|
||||
class="hide">
|
||||
<%= t("polls.show.read_less", answer: answer.title) %>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if answer.documents.present? %>
|
||||
<div class="document-link">
|
||||
<p>
|
||||
<span class="icon-document"></span>
|
||||
<strong><%= t("polls.show.documents") %></strong>
|
||||
</p>
|
||||
|
||||
<% answer.documents.each do |document| %>
|
||||
<%= link_to document.title,
|
||||
document.attachment.url,
|
||||
target: "_blank",
|
||||
rel: "nofollow" %><br>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if answer.videos.present? %>
|
||||
<div class="video-link">
|
||||
<p>
|
||||
<span class="icon-video"></span>
|
||||
<strong><%= t("polls.show.videos") %></strong>
|
||||
</p>
|
||||
|
||||
<% answer.videos.each do |video| %>
|
||||
<%= link_to video.title,
|
||||
video.url,
|
||||
target: "_blank",
|
||||
rel: "nofollow" %><br>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div id="tab-information" class="tabs-panel is-active">
|
||||
<%= render "show" %>
|
||||
</div>
|
||||
|
||||
<div class="tabs-content" data-tabs-content="proposals-tabs" role="tablist">
|
||||
<%= render "filter_subnav" %>
|
||||
|
||||
<div class="tabs-panel is-active" id="tab-comments">
|
||||
<%= render "comments" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
94
app/views/polls/stats.html.erb
Normal file
94
app/views/polls/stats.html.erb
Normal file
@@ -0,0 +1,94 @@
|
||||
<% provide :title do %><%= @poll.name %><% end %>
|
||||
|
||||
<div class="polls-show">
|
||||
<%= render "poll_header" %>
|
||||
|
||||
<%= render "poll_subnav" %>
|
||||
|
||||
<div class="row margin">
|
||||
<div class="small-12 medium-3 column sidebar">
|
||||
<p><%= t("polls.show.stats.title") %></p>
|
||||
<ul class="menu vertical margin-top">
|
||||
<li><a href="#total"><%= t("polls.show.stats.total_participation") %></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="small-12 medium-9 column">
|
||||
<h3 id="total"><%= t("polls.show.stats.total_participation") %></h3>
|
||||
|
||||
<p class="stat-number margin-top">
|
||||
<%= t("polls.show.stats.total_votes") %><br>
|
||||
<span><%= @stats[:total_participants] %></span>
|
||||
</p>
|
||||
<table class="polls-total-stats">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col"><%= t("polls.show.stats.votes") %></th>
|
||||
<th scope="col"><%= t("polls.show.stats.web") %></th>
|
||||
<th scope="col"><%= t("polls.show.stats.booth") %></th>
|
||||
<th scope="col"><%= t("polls.show.stats.total") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th><%= t("polls.show.stats.valid") %></th>
|
||||
<td><%= @stats[:total_web_valid] %> <small><em>
|
||||
(<%= number_to_percentage(@stats[:valid_percentage_web],
|
||||
strip_insignificant_zeros: true,
|
||||
precision: 2) %>)</em></small></td>
|
||||
<td><%= @stats[:total_booth_valid] %> <small><em>
|
||||
(<%= number_to_percentage(@stats[:valid_percentage_booth],
|
||||
strip_insignificant_zeros: true,
|
||||
precision: 2) %>)</em></small></td>
|
||||
<td><%= @stats[:total_valid_votes] %> <small><em>
|
||||
(<%= number_to_percentage(@stats[:total_valid_percentage],
|
||||
strip_insignificant_zeros: true,
|
||||
precision: 2) %>)</em></small></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><%= t("polls.show.stats.white") %></th>
|
||||
<td><%= @stats[:total_web_white] %> <small><em>
|
||||
(<%= number_to_percentage(@stats[:white_percentage_web],
|
||||
strip_insignificant_zeros: true,
|
||||
precision: 2) %>)</em></small></td>
|
||||
<td><%= @stats[:total_booth_white] %> <small><em>
|
||||
(<%= number_to_percentage(@stats[:white_percentage_booth],
|
||||
strip_insignificant_zeros: true,
|
||||
precision: 2) %>)</em></small></td>
|
||||
<td><%= @stats[:total_white_votes] %> <small><em>
|
||||
(<%= number_to_percentage(@stats[:total_white_percentage],
|
||||
strip_insignificant_zeros: true,
|
||||
precision: 2) %>)</em></small></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><%= t("polls.show.stats.null_votes") %></th>
|
||||
<td><%= @stats[:total_web_null] %> <small><em>
|
||||
(<%= number_to_percentage(@stats[:null_percentage_web],
|
||||
strip_insignificant_zeros: true,
|
||||
precision: 2) %>)</em></small></td>
|
||||
<td><%= @stats[:total_booth_null] %> <small><em>
|
||||
(<%= number_to_percentage(@stats[:null_percentage_booth],
|
||||
strip_insignificant_zeros: true,
|
||||
precision: 2) %>)</em></small></td>
|
||||
<td><%= @stats[:total_null_votes] %> <small><em>
|
||||
(<%= number_to_percentage(@stats[:total_null_percentage],
|
||||
strip_insignificant_zeros: true,
|
||||
precision: 2) %>)</em></small></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><%= t("polls.show.stats.total") %></th>
|
||||
<td><%= @stats[:total_participants_web] %> <small><em>
|
||||
(<%= number_to_percentage(@stats[:total_participants_web_percentage],
|
||||
strip_insignificant_zeros: true,
|
||||
precision: 2) %>)</em></small></td>
|
||||
<td><%= @stats[:total_participants_booth] %> <small><em>
|
||||
(<%= number_to_percentage(@stats[:total_participants_booth_percentage],
|
||||
strip_insignificant_zeros: true,
|
||||
precision: 2) %>)</em></small></td>
|
||||
<td><%= @stats[:total_participants_web] + @stats[:total_participants_booth] %></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -1,85 +0,0 @@
|
||||
<div class="row">
|
||||
<div class="small-12 medium-3 column sidebar">
|
||||
<p><%= t("polls.show.stats.title") %></p>
|
||||
<ul class="menu vertical margin-top">
|
||||
<li><a href="#total"><%= t("polls.show.stats.total_participation") %></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="small-12 medium-9 column">
|
||||
<h3 id="total"><%= t("polls.show.stats.total_participation") %></h3>
|
||||
|
||||
<p class="stat-number margin-top">
|
||||
<%= t("polls.show.stats.total_votes") %><br>
|
||||
<span><%= @stats[:total_participants] %></span>
|
||||
</p>
|
||||
<table class="polls-total-stats">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col"><%= t("polls.show.stats.votes") %></th>
|
||||
<th scope="col"><%= t("polls.show.stats.web") %></th>
|
||||
<th scope="col"><%= t("polls.show.stats.booth") %></th>
|
||||
<th scope="col"><%= t("polls.show.stats.total") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th><%= t("polls.show.stats.valid") %></th>
|
||||
<td><%= @stats[:total_web_valid] %> <small><em>
|
||||
(<%= number_to_percentage(@stats[:valid_percentage_web],
|
||||
strip_insignificant_zeros: true,
|
||||
precision: 2) %>)</em></small></td>
|
||||
<td><%= @stats[:total_booth_valid] %> <small><em>
|
||||
(<%= number_to_percentage(@stats[:valid_percentage_booth],
|
||||
strip_insignificant_zeros: true,
|
||||
precision: 2) %>)</em></small></td>
|
||||
<td><%= @stats[:total_valid_votes] %> <small><em>
|
||||
(<%= number_to_percentage(@stats[:total_valid_percentage],
|
||||
strip_insignificant_zeros: true,
|
||||
precision: 2) %>)</em></small></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><%= t("polls.show.stats.white") %></th>
|
||||
<td><%= @stats[:total_web_white] %> <small><em>
|
||||
(<%= number_to_percentage(@stats[:white_percentage_web],
|
||||
strip_insignificant_zeros: true,
|
||||
precision: 2) %>)</em></small></td>
|
||||
<td><%= @stats[:total_booth_white] %> <small><em>
|
||||
(<%= number_to_percentage(@stats[:white_percentage_booth],
|
||||
strip_insignificant_zeros: true,
|
||||
precision: 2) %>)</em></small></td>
|
||||
<td><%= @stats[:total_white_votes] %> <small><em>
|
||||
(<%= number_to_percentage(@stats[:total_white_percentage],
|
||||
strip_insignificant_zeros: true,
|
||||
precision: 2) %>)</em></small></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><%= t("polls.show.stats.null_votes") %></th>
|
||||
<td><%= @stats[:total_web_null] %> <small><em>
|
||||
(<%= number_to_percentage(@stats[:null_percentage_web],
|
||||
strip_insignificant_zeros: true,
|
||||
precision: 2) %>)</em></small></td>
|
||||
<td><%= @stats[:total_booth_null] %> <small><em>
|
||||
(<%= number_to_percentage(@stats[:null_percentage_booth],
|
||||
strip_insignificant_zeros: true,
|
||||
precision: 2) %>)</em></small></td>
|
||||
<td><%= @stats[:total_null_votes] %> <small><em>
|
||||
(<%= number_to_percentage(@stats[:total_null_percentage],
|
||||
strip_insignificant_zeros: true,
|
||||
precision: 2) %>)</em></small></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><%= t("polls.show.stats.total") %></th>
|
||||
<td><%= @stats[:total_participants_web] %> <small><em>
|
||||
(<%= number_to_percentage(@stats[:total_participants_web_percentage],
|
||||
strip_insignificant_zeros: true,
|
||||
precision: 2) %>)</em></small></td>
|
||||
<td><%= @stats[:total_participants_booth] %> <small><em>
|
||||
(<%= number_to_percentage(@stats[:total_participants_booth_percentage],
|
||||
strip_insignificant_zeros: true,
|
||||
precision: 2) %>)</em></small></td>
|
||||
<td><%= @stats[:total_participants_web] + @stats[:total_participants_booth] %></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@@ -113,6 +113,7 @@ Rails.application.routes.draw do
|
||||
end
|
||||
|
||||
resources :polls, only: [:show, :index] do
|
||||
get :stats
|
||||
get :results
|
||||
resources :questions, controller: 'polls/questions', shallow: true do
|
||||
post :answer, on: :member
|
||||
|
||||
Reference in New Issue
Block a user