adds officing's polls index
This commit is contained in:
8
app/controllers/officing/polls_controller.rb
Normal file
8
app/controllers/officing/polls_controller.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
class Officing::PollsController < Officing::BaseController
|
||||
|
||||
def index
|
||||
@polls = current_user.poll_officer? ? current_user.poll_officer.assigned_polls : []
|
||||
@polls = @polls.select {|poll| poll.current?(1.day.ago)}
|
||||
end
|
||||
|
||||
end
|
||||
@@ -13,5 +13,6 @@ class Poll
|
||||
map(&:poll).uniq.compact.
|
||||
sort {|x, y| y.ends_at <=> x.ends_at}
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -8,10 +8,10 @@
|
||||
<% end %>
|
||||
</li>
|
||||
|
||||
<li <%= "class=active" if controller_name == "results" %>>
|
||||
<%= link_to new_officing_poll_result_path(Poll.last) do %>
|
||||
<li <%= "class=active" if ["polls", "recounts"].include?(controller_name) %>>
|
||||
<%= link_to officing_polls_path do %>
|
||||
<span class="icon-user"></span>
|
||||
<%= t("officing.menu.results") %>
|
||||
<%= t("officing.menu.recounts") %>
|
||||
<% end %>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
30
app/views/officing/polls/index.html.erb
Normal file
30
app/views/officing/polls/index.html.erb
Normal file
@@ -0,0 +1,30 @@
|
||||
<h2><%= t("officing.polls.index.title") %></h2>
|
||||
|
||||
<% if @polls.any? %>
|
||||
<table>
|
||||
<thead>
|
||||
<th><%= t("officing.polls.index.select_poll") %></th>
|
||||
<th> </th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @polls.each do |poll| %>
|
||||
<tr id="<%= dom_id(poll) %>" class="poll">
|
||||
<td>
|
||||
<strong>
|
||||
<%= link_to poll.name, new_officing_poll_recount_path(poll) %>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<%= link_to t("officing.polls.index.add_recount"),
|
||||
new_officing_poll_recount_path(poll),
|
||||
class: "button hollow" %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% else %>
|
||||
<div class="callout primary">
|
||||
<%= t("officing.polls.index.no_polls") %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -7,7 +7,13 @@ en:
|
||||
info: Here you can validate user documents and store voting results
|
||||
menu:
|
||||
voters: Validate document
|
||||
results: Store results
|
||||
recounts: Store recount
|
||||
polls:
|
||||
index:
|
||||
title: Poll list
|
||||
no_polls: You are not officing in any active poll
|
||||
select_poll: Select poll
|
||||
add_recount: Add recount
|
||||
voters:
|
||||
new:
|
||||
title: Validate document
|
||||
|
||||
@@ -6,8 +6,14 @@ es:
|
||||
title: Presidir mesa de votaciones
|
||||
info: Aquí puedes validar documentos de ciudadanos y guardar los resultados de las urnas
|
||||
menu:
|
||||
voters: Validar documento
|
||||
results: Guardar resultados
|
||||
voters: "Validar documento"
|
||||
recounts: "Guardar recuento"
|
||||
polls:
|
||||
index:
|
||||
title: "Listado de votaciones"
|
||||
no_polls: "No eres presidente de mesa en ninguna votación activa"
|
||||
select_poll: "Selecciona votación"
|
||||
add_recount: "Añadir recuento"
|
||||
voters:
|
||||
new:
|
||||
title: Validar documento
|
||||
|
||||
@@ -289,7 +289,7 @@ Rails.application.routes.draw do
|
||||
end
|
||||
|
||||
namespace :officing do
|
||||
resources :polls do
|
||||
resources :polls, only: [:index] do
|
||||
resources :voters, only: [:new, :show]
|
||||
resources :results, only: [:new, :index, :show]
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user