Denormalizes booth_assignmen on the models where it is needed

This commit is contained in:
kikito
2017-02-11 12:43:05 +01:00
committed by Javi Martín
parent 10283c32ee
commit 34dfeee9c9

View File

@@ -16,7 +16,7 @@ class Poll
validates :document_number, presence: true, uniqueness: { scope: [:poll_id, :document_type], message: :has_voted }
validates :origin, inclusion: { in: VALID_ORIGINS }
before_validation :set_demographic_info, :set_document_info
before_validation :set_demographic_info, :set_document_info, :set_denormalized_booth_assignment_id
scope :web, -> { where(origin: "web") }
scope :booth, -> { where(origin: "booth") }
@@ -38,6 +38,10 @@ class Poll
private
def set_denormalized_booth_assignment_id
self.booth_assignment_id ||= officer_assignment.try(:booth_assignment_id)
end
def in_census?
census_api_response.valid?
end