diff --git a/app/controllers/admin/poll/officer_assignments_controller.rb b/app/controllers/admin/poll/officer_assignments_controller.rb index 1f2a7ca2c..45c9a225a 100644 --- a/app/controllers/admin/poll/officer_assignments_controller.rb +++ b/app/controllers/admin/poll/officer_assignments_controller.rb @@ -32,35 +32,6 @@ class Admin::Poll::OfficerAssignmentsController < Admin::BaseController end end - def create - @officer_assignment = ::Poll::OfficerAssignment.new(booth_assignment: @booth_assignment, - officer_id: create_params[:officer_id], - date: create_params[:date]) - @officer_assignment.final = true if @officer_assignment.date > @booth_assignment.poll.ends_at.to_date - - if @officer_assignment.save - notice = t("admin.poll_officer_assignments.flash.create") - else - notice = t("admin.poll_officer_assignments.flash.error_create") - end - - redirect_params = { poll_id: create_params[:poll_id], officer_id: create_params[:officer_id] } - redirect_to by_officer_admin_poll_officer_assignments_path(redirect_params), notice: notice - end - - def destroy - @officer_assignment = ::Poll::OfficerAssignment.includes(:booth_assignment).find(params[:id]) - - if @officer_assignment.destroy - notice = t("admin.poll_officer_assignments.flash.destroy") - else - notice = t("admin.poll_officer_assignments.flash.error_destroy") - end - - redirect_params = { poll_id: @officer_assignment.poll_id, officer_id: @officer_assignment.officer_id } - redirect_to by_officer_admin_poll_officer_assignments_path(redirect_params), notice: notice - end - private def officer_assignment_params diff --git a/app/views/admin/poll/officer_assignments/by_officer.html.erb b/app/views/admin/poll/officer_assignments/by_officer.html.erb index 6e505040e..8cc6c0437 100644 --- a/app/views/admin/poll/officer_assignments/by_officer.html.erb +++ b/app/views/admin/poll/officer_assignments/by_officer.html.erb @@ -5,35 +5,6 @@

<%= @officer.name %> - <%= @officer.email %>

-<%= form_tag(admin_poll_officer_assignments_path(@poll), {id: "officer_assignment_form"}) do %> -
- <%= t("admin.poll_officer_assignments.by_officer.new_assignment") %> -
- - <%= select_tag :date, - poll_dates_select_options(@poll) + poll_final_recount_option(@poll), - { prompt: t("admin.poll_officer_assignments.by_officer.select_date"), - label: false } %> -
- -
- - <%= select_tag :booth_id, - poll_booths_select_options(@poll), - { prompt: t("admin.poll_officer_assignments.by_officer.select_booth"), - label: false } %> -
- -
- <%= hidden_field_tag :officer_id, @officer.id %> - <%= hidden_field_tag :poll_id, @poll.id %> - <%= submit_tag t("admin.poll_officer_assignments.by_officer.add_assignment"), - class: "button expanded hollow margin-top" %> -
-
-<% end %> - - <% if @officer_assignments.empty? %>
<%= t("admin.poll_officer_assignments.by_officer.no_assignments") %> @@ -45,7 +16,6 @@ <%= t("admin.poll_officer_assignments.by_officer.date") %> <%= t("admin.poll_officer_assignments.by_officer.booth") %> - <%= t("admin.poll_officer_assignments.by_officer.assignment") %> @@ -53,12 +23,6 @@ <%= officer_assignment.final? ? t('polls.final_date') : l(officer_assignment.date.to_date) %> <%= booth_name_with_location(officer_assignment.booth_assignment.booth) %> - - <%= link_to t("admin.poll_officer_assignments.by_officer.remove_assignment"), - admin_poll_officer_assignment_path(@poll, officer_assignment), - method: :delete, - class: "button hollow alert" %> - <% end %> @@ -93,6 +57,3 @@ <% end %> - - - diff --git a/spec/features/admin/poll/officer_assignments_spec.rb b/spec/features/admin/poll/officer_assignments_spec.rb deleted file mode 100644 index 08cbd3f99..000000000 --- a/spec/features/admin/poll/officer_assignments_spec.rb +++ /dev/null @@ -1,91 +0,0 @@ -require 'rails_helper' - -feature 'Admin officer assignments in poll' do - - background do - admin = create(:administrator) - login_as(admin.user) - end - - scenario 'Assign officer to poll', :js do - booth_assignment = create(:poll_booth_assignment) - officer = create(:poll_officer) - - visit admin_poll_path(booth_assignment.poll) - within('#poll-resources') do - click_link 'Officers (0)' - end - - expect(page).to have_content 'There are no officers assigned to this poll' - - fill_in 'search-officers', with: officer.name - click_button 'Search' - - within('#search-officers-results') do - click_link 'Add shifts as officer' - end - - expect(page).to have_content 'This user has no officing shifts in this poll' - expect(page).to have_content officer.name - expect(page).to have_content booth_assignment.poll.name - - within('#officer_assignment_form') do - select I18n.l(booth_assignment.poll.ends_at.to_date, format: :long), from: 'date' - select "#{booth_assignment.booth.name} (#{booth_assignment.booth.location})", from: 'booth_id' - click_button 'Add shift' - end - - expect(page).to have_content 'Officing shift added' - expect(page).to_not have_content 'This user has no officing shifts in this poll' - - visit admin_poll_path(booth_assignment.poll) - within('#poll-resources') do - click_link 'Officers (1)' - end - - expect(page).to_not have_content 'There are no officers in this poll' - expect(page).to have_content officer.name - expect(page).to have_content officer.email - end - - scenario 'Remove officer assignment from poll' do - officer_assignment = create(:poll_officer_assignment) - poll = officer_assignment.booth_assignment.poll - booth = officer_assignment.booth_assignment.booth - officer = officer_assignment.officer - - visit by_officer_admin_poll_officer_assignments_path(poll, officer_id: officer.id) - - expect(page).to_not have_content 'This user has no officing shifts in this poll' - within("#poll_officer_assignment_#{officer_assignment.id}") do - expect(page).to have_content booth.name - click_link 'Remove' - end - - expect(page).to have_content 'Officing shift removed' - expect(page).to have_content 'This user has no officing shifts in this poll' - end - - scenario 'Index view shows recounts info for officer' do - booth_assignment = create(:poll_booth_assignment) - poll = booth_assignment.poll - officer = create(:poll_officer) - create(:poll_officer_assignment, - booth_assignment: booth_assignment, - officer: officer, - date: poll.starts_at) - final_officer_assignment = create(:poll_officer_assignment, :final, - booth_assignment: booth_assignment, - officer: officer, - date: poll.ends_at + 1.day) - create(:poll_final_recount, - booth_assignment: booth_assignment, - officer_assignment: final_officer_assignment, - date: poll.ends_at, - count: 9876) - - visit by_officer_admin_poll_officer_assignments_path(poll, officer_id: officer.id) - - within('#final_recount_list') { expect(page).to have_content('9876') } - end -end