First steps to destroy shifts when booth_assignments are destroyed

This commit is contained in:
iagirre
2017-10-27 14:57:32 +02:00
parent b854d99248
commit 89425f50ef
3 changed files with 19 additions and 1 deletions

View File

@@ -90,4 +90,8 @@ class Poll < ActiveRecord::Base
end
end
def shifts_in_booth(booth_id)
officer_assignments.where(booth_assignment_id: booth_assignments.where(booth_id: booth_id).pluck(:id)).pluck(:officer_id).uniq
end
end

View File

@@ -8,5 +8,18 @@ class Poll
has_many :voters
has_many :partial_results
has_many :recounts
before_destroy :destroy_poll_shifts
def has_shifts?
end
private
def destroy_poll_shifts
# officers = poll.officers_in_booth(booth.id)
# Poll::Shift.where(officer_id: officers, booth_id: booth.id)
end
end
end

View File

@@ -14,7 +14,8 @@
method: :delete,
remote: true,
title: t("admin.booth_assignments.manage.actions.unassign"),
class: "button hollow alert #{@poll.expired? ? 'disabled' : ''}" %>
class: "button hollow alert #{@poll.expired? ? 'disabled' : ''}",
data: (booth_assignment.has_shifts? ? {confirm: "Are you sure?"} : nil) %>
</td>
<% else %>
<td>