Denormalizes booth_assignmen on the models where it is needed
This commit is contained in:
@@ -16,7 +16,7 @@ class Poll
|
|||||||
validates :document_number, presence: true, uniqueness: { scope: [:poll_id, :document_type], message: :has_voted }
|
validates :document_number, presence: true, uniqueness: { scope: [:poll_id, :document_type], message: :has_voted }
|
||||||
validates :origin, inclusion: { in: VALID_ORIGINS }
|
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 :web, -> { where(origin: "web") }
|
||||||
scope :booth, -> { where(origin: "booth") }
|
scope :booth, -> { where(origin: "booth") }
|
||||||
@@ -38,6 +38,10 @@ class Poll
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def set_denormalized_booth_assignment_id
|
||||||
|
self.booth_assignment_id ||= officer_assignment.try(:booth_assignment_id)
|
||||||
|
end
|
||||||
|
|
||||||
def in_census?
|
def in_census?
|
||||||
census_api_response.valid?
|
census_api_response.valid?
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user