Destroy all related OfficerAssignments when destroying a Shift
This commit is contained in:
@@ -12,6 +12,7 @@ class Poll
|
||||
|
||||
before_create :persist_data
|
||||
after_create :create_officer_assignments
|
||||
before_destroy :destroy_officer_assignments
|
||||
|
||||
def persist_data
|
||||
self.officer_name = officer.name
|
||||
@@ -29,5 +30,12 @@ class Poll
|
||||
Poll::OfficerAssignment.create!(attrs)
|
||||
end
|
||||
end
|
||||
|
||||
def destroy_officer_assignments
|
||||
Poll::OfficerAssignment.where(booth_assignment: booth.booth_assignments,
|
||||
officer: officer,
|
||||
date: date,
|
||||
final: recount_scrutiny?).destroy_all
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user