Files
grecia/app/models/poll/officer_assignment.rb
Juanjo Bazán d7000e399f logs user info in officer_assignments
In case user is no longer a poll officer, info on who did what is
stored in officer_assignment
2017-02-08 15:50:13 +01:00

26 lines
721 B
Ruby

class Poll
class OfficerAssignment < ActiveRecord::Base
belongs_to :officer
belongs_to :booth_assignment
has_one :recount
has_many :final_recounts
has_many :partial_results
has_many :voters
validates :officer_id, presence: true
validates :booth_assignment_id, presence: true
validates :date, presence: true, uniqueness: { scope: [:officer_id, :booth_assignment_id] }
delegate :poll_id, :booth_id, to: :booth_assignment
scope :voting_days, -> { where(final: false) }
scope :final, -> { where(final: true) }
before_create :log_user_data
def log_user_data
self.user_data_log = "#{officer.user_id} - #{officer.user.name_and_email}"
end
end
end