adds validations and info logging to Recount
This commit is contained in:
@@ -3,13 +3,18 @@ class Poll
|
||||
belongs_to :booth_assignment, class_name: "Poll::BoothAssignment"
|
||||
belongs_to :officer_assignment, class_name: "Poll::OfficerAssignment"
|
||||
|
||||
validates :booth_assignment_id, presence: true
|
||||
validates :date, presence: true, uniqueness: {scope: :booth_assignment_id}
|
||||
validates :officer_assignment_id, presence: true, uniqueness: {scope: :booth_assignment_id}
|
||||
validates :count, presence: true
|
||||
validates :count, presence: true, numericality: {only_integer: true}
|
||||
|
||||
before_save :update_count_log
|
||||
before_save :update_logs
|
||||
|
||||
def update_count_log
|
||||
self.count_log += ":#{self.count_was.to_s}" if self.count_changed? && self.count_was.present?
|
||||
def update_logs
|
||||
if self.count_changed? && self.count_was.present?
|
||||
self.count_log += ":#{self.count_was.to_s}"
|
||||
self.officer_assignment_id_log += ":#{self.officer_assignment_id_was.to_s}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user