Add Poll booth_assignments and :Poll::BoothAssignment manage routes, actions and views

This commit is contained in:
Bertocq
2017-10-19 19:27:26 +02:00
parent 3daf957813
commit 45d91a7e50
9 changed files with 64 additions and 4 deletions

View File

@@ -45,6 +45,10 @@ class Admin::Poll::BoothAssignmentsController < Admin::Poll::BaseController
redirect_to admin_poll_booth_assignments_path(@booth_assignment.poll_id), notice: notice
end
def manage
@booths = ::Poll::Booth.all
end
private
def load_booth_assignment

View File

@@ -47,6 +47,10 @@ class Admin::Poll::PollsController < Admin::Poll::BaseController
redirect_to admin_poll_path(@poll), notice: notice
end
def booth_assignments
@polls = Poll.current_or_incoming
end
private
def load_geozones

View File

@@ -56,10 +56,10 @@ module Abilities
can [:index, :create, :edit, :update, :destroy], Geozone
can [:read, :create, :update, :destroy, :add_question, :search_booths, :search_officers], Poll
can [:read, :create, :update, :destroy, :add_question, :search_booths, :search_officers, :booth_assignments], Poll
can [:read, :create, :update, :destroy, :available], Poll::Booth
can [:search, :create, :index, :destroy], ::Poll::Officer
can [:create, :destroy], ::Poll::BoothAssignment
can [:create, :destroy, :manage], ::Poll::BoothAssignment
can [:create, :destroy], ::Poll::OfficerAssignment
can [:read, :create, :update], Poll::Question
can :destroy, Poll::Question # , comments_count: 0, votes_up: 0

View File

@@ -60,7 +60,8 @@
<strong><%= t("admin.menu.title_polls") %></strong>
</a>
<ul id="polls_menu" <%= "class=is-active" if menu_polls? || controller.class.parent == Admin::Poll::Questions::Answers %>>
<li <%= "class=active" if ["polls", "officer_assignments", "booth_assignments", "recounts", "results"].include? controller_name %>>
<li <%= "class=active" if ["polls", "officer_assignments", "booth_assignments", "recounts", "results"].include? controller_name &&
action_name != "booth_assignments" %>>
<%= link_to t('admin.menu.polls'), admin_polls_path %>
</li>
@@ -84,6 +85,10 @@
action_name == "available" %>>
<%= link_to t('admin.menu.poll_shifts'), available_admin_booths_path %>
</li>
<li <%= "class=active" if (controller_name == "polls" && action_name == "booth_assignments") || (controller_name == "booth_assignments" && action_name == "manage") %>>
<%= link_to t('admin.menu.poll_booth_assignments'), booth_assignments_admin_polls_path %>
</li>
</ul>
</li>
<% end %>

View File

@@ -0,0 +1,25 @@
<h2 class="inline-block"><%= t("admin.booths.index.title") %></h2>
<% if controller_name == "booths" && action_name != "available" %>
<%= link_to t("admin.booths.index.add_booth"), new_admin_booth_path, class: "button success float-right" %>
<% end %>
<% if @booths.empty? %>
<div class="callout primary">
<%= t("admin.booths.index.no_booths") %>
</div>
<% end %>
<% if @booths.any? %>
<table>
<thead>
<th><%= t("admin.booths.index.name") %></th>
<th class="text-right"><%= t("admin.actions.actions") %></th>
</thead>
<tbody>
<% @booths.each do |booth| %>
<% end %>
</tbody>
</table>
<% end %>

View File

@@ -0,0 +1,18 @@
<h2 class="inline-block"><%= t("admin.polls.index.title") %></h2>
<% if @polls.any? %>
<table>
<thead>
<th class="medium-6"><%= t("admin.polls.index.name") %></th>
<th><%= t("admin.polls.index.dates") %></th>
<th class="text-right"><%= t("admin.actions.actions") %></th>
</thead>
<tbody>
<%= render @polls %>
</tbody>
</table>
<% else %>
<div class="callout primary">
<%= t("admin.polls.index.no_polls") %>
</div>
<% end %>

View File

@@ -409,6 +409,7 @@ en:
poll_officers: Poll officers
polls: Polls
poll_booths: Booths location
poll_booth_assignments: Booths Assignments
poll_shifts: Manage shifts
officials: Officials
organizations: Organisations

View File

@@ -420,6 +420,7 @@ es:
poll_officers: Presidentes de mesa
polls: Votaciones
poll_booths: Ubicación de urnas
poll_booth_assignments: Asignación de urnas
poll_shifts: Asignar turnos
officials: Cargos públicos
organizations: Organizaciones

View File

@@ -111,7 +111,7 @@ Rails.application.routes.draw do
resources :annotations do
get :search, on: :collection
end
resources :polls, only: [:show, :index] do
resources :questions, controller: 'polls/questions', shallow: true do
post :answer, on: :member
@@ -273,10 +273,12 @@ Rails.application.routes.draw do
scope module: :poll do
resources :polls do
get :booth_assignments, on: :collection
patch :add_question, on: :member
resources :booth_assignments, only: [:index, :show, :create, :destroy] do
get :search_booths, on: :collection
get :manage, on: :collection
end
resources :officer_assignments, only: [:index, :create, :destroy] do