|
|
|
@ -5,6 +5,7 @@ class Location < ApplicationRecord |
|
|
|
validate :validate_units, on: :units |
|
|
|
validate :validate_units, on: :units |
|
|
|
validate :validate_type_of_unit, on: :type_of_unit |
|
|
|
validate :validate_type_of_unit, on: :type_of_unit |
|
|
|
validate :validate_mobility_type, on: :mobility_type |
|
|
|
validate :validate_mobility_type, on: :mobility_type |
|
|
|
|
|
|
|
validate :validate_startdate, on: :startdate |
|
|
|
belongs_to :scheme |
|
|
|
belongs_to :scheme |
|
|
|
has_many :lettings_logs, class_name: "LettingsLog" |
|
|
|
has_many :lettings_logs, class_name: "LettingsLog" |
|
|
|
has_many :location_deactivation_periods, class_name: "LocationDeactivationPeriod" |
|
|
|
has_many :location_deactivation_periods, class_name: "LocationDeactivationPeriod" |
|
|
|
@ -442,6 +443,13 @@ class Location < ApplicationRecord |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def validate_startdate |
|
|
|
|
|
|
|
unless startdate.between?(Time.zone.local(1900, 1, 1), Time.zone.local(2200, 1, 1)) |
|
|
|
|
|
|
|
error_message = I18n.t("validations.location.startdate_out_of_range") |
|
|
|
|
|
|
|
errors.add :startdate, error_message |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
private |
|
|
|
private |
|
|
|
|
|
|
|
|
|
|
|
PIO = PostcodeService.new |
|
|
|
PIO = PostcodeService.new |
|
|
|
|