Browse Source

CDLC-504: Only changes the status after validation

pull/207/head
Stéphane Meny 4 years ago
parent
commit
b103184779
No known key found for this signature in database
GPG Key ID: 9D0AFEA988527923
  1. 6
      app/models/case_log.rb

6
app/models/case_log.rb

@ -35,9 +35,10 @@ class CaseLog < ApplicationRecord
default_scope -> { kept } default_scope -> { kept }
validates_with CaseLogValidator validates_with CaseLogValidator
before_validation :update_status! before_save :update_status!
before_validation :process_postcode_changes!, if: :property_postcode_changed? before_validation :process_postcode_changes!, if: :property_postcode_changed?
before_validation :reset_location_fields!, unless: :postcode_known? before_validation :reset_location_fields!, unless: :postcode_known?
before_validation :set_derived_fields!
belongs_to :owning_organisation, class_name: "Organisation" belongs_to :owning_organisation, class_name: "Organisation"
belongs_to :managing_organisation, class_name: "Organisation" belongs_to :managing_organisation, class_name: "Organisation"
@ -203,10 +204,9 @@ private
else else
"in_progress" "in_progress"
end end
set_derived_fields
end end
def set_derived_fields def set_derived_fields!
if previous_postcode.present? if previous_postcode.present?
self.ppostc1 = UKPostcode.parse(previous_postcode).outcode self.ppostc1 = UKPostcode.parse(previous_postcode).outcode
self.ppostc2 = UKPostcode.parse(previous_postcode).incode self.ppostc2 = UKPostcode.parse(previous_postcode).incode

Loading…
Cancel
Save