First steps to destroy shifts when booth_assignments are destroyed
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user