diff --git a/app/controllers/admin/poll/booths_controller.rb b/app/controllers/admin/poll/booths_controller.rb
index 1d05ddab5..ff3700436 100644
--- a/app/controllers/admin/poll/booths_controller.rb
+++ b/app/controllers/admin/poll/booths_controller.rb
@@ -1,14 +1,11 @@
class Admin::Poll::BoothsController < Admin::BaseController
- load_and_authorize_resource :poll
- load_and_authorize_resource class: 'Poll::Booth', through: :poll
-
- before_action :load_polls, only: :index
+ load_and_authorize_resource class: 'Poll::Booth'
def index
+ @booths = @booths.order(name: :asc).page(params[:page])
end
def show
- @officers = Poll::Officer.all
end
def new
@@ -16,7 +13,7 @@ class Admin::Poll::BoothsController < Admin::BaseController
def create
if @booth.save
- redirect_to admin_poll_booth_path(@poll, @booth), notice: t("flash.actions.create.poll_booth")
+ redirect_to admin_booths_path, notice: t("flash.actions.create.poll_booth")
else
render :new
end
@@ -27,7 +24,7 @@ class Admin::Poll::BoothsController < Admin::BaseController
def update
if @booth.update(booth_params)
- redirect_to admin_poll_booth_path(@poll, @booth), notice: t("flash.actions.update.poll_booth")
+ redirect_to admin_booth_path(@booth), notice: t("flash.actions.update.poll_booth")
else
render :edit
end
@@ -36,11 +33,7 @@ class Admin::Poll::BoothsController < Admin::BaseController
private
def booth_params
- params.require(:poll_booth).permit(:name, :location, officer_ids: [])
- end
-
- def load_polls
- @polls = Poll.all
+ params.require(:poll_booth).permit(:name, :location)
end
end
\ No newline at end of file
diff --git a/app/views/admin/poll/booths/_booth.html.erb b/app/views/admin/poll/booths/_booth.html.erb
index ff1683867..5bccfa9c6 100644
--- a/app/views/admin/poll/booths/_booth.html.erb
+++ b/app/views/admin/poll/booths/_booth.html.erb
@@ -1,18 +1,15 @@
- <%= form_tag '', method: :get do %>
- <%= select_tag "poll_id",
- options_for_select(@polls.collect {|poll|
- [poll.name, admin_poll_booths_path(poll)]
- }),
- prompt: t("admin.booths.index.select_poll"),
- class: "js-location-changer" %>
- <% end %>
-
-
-
<%= t("admin.booths.index.no_booths") %>
@@ -20,19 +7,22 @@
<% end %>
<%= link_to t("admin.booths.index.add_booth"),
- new_admin_poll_booth_path(@poll),
+ new_admin_booth_path,
class: "button success" %>
-
-
- | <%= t("admin.booths.index.name") %> |
- <%= t("admin.booths.index.location") %> |
- <%= t("admin.booths.index.officers") %> |
- |
-
-
- <% @booths.each do |booth| %>
- <%= render partial: "booth", locals: { booth: booth } %>
- <% end %>
-
-
+<% if @booths.any? %>
+
+
+ | <%= t("admin.booths.index.name") %> |
+ <%= t("admin.booths.index.location") %> |
+ |
+
+
+ <% @booths.each do |booth| %>
+ <%= render partial: "booth", locals: { booth: booth } %>
+ <% end %>
+
+
+
+ <%= paginate @booths %>
+<% end %>
diff --git a/app/views/admin/poll/booths/new.html.erb b/app/views/admin/poll/booths/new.html.erb
index cffcfab72..cf9581fa3 100644
--- a/app/views/admin/poll/booths/new.html.erb
+++ b/app/views/admin/poll/booths/new.html.erb
@@ -1,7 +1,7 @@
-<%= render 'shared/back_link' %>
+<%= back_link_to admin_booths_path %>
-
<%= t("admin.booths.new.title", poll: @poll.name) %>: <%= t("admin.booths.new.subtitle") %>
+
<%= t("admin.booths.new.title") %>
-<%= form_for @booth, url: admin_poll_booths_path(@poll) do |f| %>
+<%= form_for @booth, url: admin_booths_path(@booth) do |f| %>
<%= render "form", f: f %>
<% end %>
\ No newline at end of file
diff --git a/app/views/admin/poll/booths/show.html.erb b/app/views/admin/poll/booths/show.html.erb
index cce704d2c..4d21f32e3 100644
--- a/app/views/admin/poll/booths/show.html.erb
+++ b/app/views/admin/poll/booths/show.html.erb
@@ -1,55 +1,15 @@
-<%= render 'shared/back_link' %>
+<%= back_link_to admin_booths_path %>
+
<%= @booth.name %>
<%= link_to t("admin.actions.edit"),
- edit_admin_poll_booth_path(@poll, @booth),
+ edit_admin_booth_path(@booth),
class: "button hollow float-right" %>
<%= t("admin.booths.show.location") %>:
<%= @booth.location %>
-
-
<%= t("admin.booths.show.officers_list") %>
-
-<% if @booth.officers.empty? %>
-
- <%= t("admin.booths.show.no_officers") %>
-
-<% end %>
-
-
- <%= form_for @booth, url: admin_poll_booth_path(@poll, @booth) do |f| %>
-
- <%= f.label :officer_ids, t("admin.spending_proposals.edit.assigned_valuators") %>
- <%= f.collection_check_boxes :officer_ids, @officers, :id, :email do |b| %>
- <% b.label { b.check_box + truncate(officer_label(b.object), length: 60) } %>
- <% end %>
-
- <%= f.submit t("admin.booths.show.assign_officer"), class: "button success" %>
- <% end %>
-
-
-
- <% @booth.officers.each do |officer| %>
-
- |
- <%= officer.name %>
- |
-
- <%= officer.email %>
- |
-
- <%= link_to t('admin.poll_officers.officer.delete'), "#", class: "button hollow alert" %>
- <%# link_to t('admin.poll_officers.officer.delete'),
- admin_poll_officer_path(Poll.last, officer),
- method: :delete,
- class: "button hollow alert"
- %>
- |
-
- <% end %>
-
\ No newline at end of file
diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml
index 0facc0935..63039d6e3 100755
--- a/config/locales/admin.en.yml
+++ b/config/locales/admin.en.yml
@@ -202,23 +202,18 @@ en:
booths:
index:
title: "List of booths"
- select_poll: "Select a poll"
- title_list: "List of booths of poll %{poll}"
- no_booths: "There are no booths in this poll."
+ no_booths: "There are no booths."
add_booth: "Add booth"
name: "Name"
location: "Location"
- officers: "Officers"
new:
- title: "Poll %{poll}"
- subtitle: "New booth"
+ title: "New booth"
name: "Name"
reference: "Reference number"
location: "Location"
submit_button: "Create booth"
edit:
- title: "Poll %{poll}"
- subtitle: "Edit booth"
+ title: "Edit booth"
name: "Name"
reference: "Reference number"
location: "Location"
diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml
index ee412368a..af948e799 100644
--- a/config/locales/admin.es.yml
+++ b/config/locales/admin.es.yml
@@ -202,23 +202,18 @@ es:
booths:
index:
title: "Lista de urnas"
- select_poll: "Selecciona una votación"
- title_list: "Lista de urnas de la votación %{poll}"
- no_booths: "No hay urnas en esta votación."
+ no_booths: "No hay urnas."
add_booth: "Añadir urna"
name: "Nombre"
location: "Ubicación"
- officers: "Presidentes de mesa"
new:
- title: "Votación %{poll}"
- subtitle: "Nueva urna"
+ title: "Nueva urna"
name: "Nombre"
reference: "Número de referencia"
location: "Ubicación"
submit_button: "Crear urna"
edit:
- title: "Votación %{poll}"
- subtitle: "Editar urna"
+ title: "Editar urna"
name: "Nombre"
reference: "Número de referencia"
location: "Ubicación"
diff --git a/config/routes.rb b/config/routes.rb
index ceecf3d88..586e8078d 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -187,9 +187,8 @@ Rails.application.routes.draw do
resources :officers do
get :search, on: :collection
end
- resources :polls do
- resources :booths
- end
+ resources :polls
+ resources :booths
resources :questions
end
diff --git a/spec/features/admin/poll/booths_spec.rb b/spec/features/admin/poll/booths_spec.rb
index eff653dfe..a5fc9e6c0 100644
--- a/spec/features/admin/poll/booths_spec.rb
+++ b/spec/features/admin/poll/booths_spec.rb
@@ -2,8 +2,6 @@ require 'rails_helper'
feature 'Admin booths' do
- let!(:poll) { create(:poll) }
-
background do
admin = create(:administrator)
login_as(admin.user)
@@ -13,25 +11,21 @@ feature 'Admin booths' do
visit admin_root_path
within('#side_menu') do
- click_link "Polls"
+ click_link "Booths"
end
- click_link poll.name
-
- expect(page).to have_content "There are no booths in this poll"
+ expect(page).to have_content "There are no booths"
end
scenario 'Index' do
- 3.times { create(:poll_booth, poll: poll) }
+ 3.times { create(:poll_booth) }
visit admin_root_path
within('#side_menu') do
- click_link "Polls"
+ click_link "Booths"
end
- click_link poll.name
-
booths = Poll::Booth.all
booths.each do |booth|
within("#booth_#{booth.id}") do
@@ -43,9 +37,9 @@ feature 'Admin booths' do
end
scenario 'Show' do
- booth = create(:poll_booth, poll: poll)
+ booth = create(:poll_booth)
- visit admin_poll_booths_path(poll)
+ visit admin_booths_path
click_link booth.name
expect(page).to have_content booth.name
@@ -53,47 +47,41 @@ feature 'Admin booths' do
end
scenario "Create" do
- visit admin_poll_booths_path(poll)
+ visit admin_booths_path
click_link "Add booth"
- expect(page).to have_content "Poll #{poll.name}"
-
fill_in "poll_booth_name", with: "Upcoming booth"
fill_in "poll_booth_location", with: "39th Street, number 2, ground floor"
click_button "Create booth"
expect(page).to have_content "Booth created successfully"
+
+ visit admin_booths_path
expect(page).to have_content "Upcoming booth"
expect(page).to have_content "39th Street, number 2, ground floor"
end
scenario "Edit" do
- booth = create(:poll_booth, poll: poll)
+ booth = create(:poll_booth)
- visit admin_poll_booths_path(poll)
+ visit admin_booths_path
- click_link "Edit"
-
- expect(page).to have_content "Poll #{poll.name}"
+ within("#booth_#{booth.id}") do
+ click_link "Edit"
+ end
fill_in "poll_booth_name", with: "Next booth"
fill_in "poll_booth_location", with: "40th Street, number 1, firts floor"
click_button "Update booth"
expect(page).to have_content "Booth updated successfully"
- expect(page).to have_content "Next booth"
- expect(page).to have_content "40th Street, number 1, firts floor"
- end
- scenario 'Edit from index' do
- booth = create(:poll_booth, poll: poll)
- visit admin_poll_booths_path(poll)
+ visit admin_booths_path
within("#booth_#{booth.id}") do
- click_link "Edit"
+ expect(page).to have_content "Next booth"
+ expect(page).to have_content "40th Street, number 1, firts floor"
end
-
- expect(current_path).to eq(edit_admin_poll_booth_path(poll, booth))
end
end
\ No newline at end of file
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index c1d391b66..494cb84a3 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -102,5 +102,4 @@ RSpec.configure do |config|
# as the one that triggered the failure.
Kernel.srand config.seed
-
end