mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 18:29:40 +02:00
Merge branch 'story/114871365-address-cc-upcase' into staging
This commit is contained in:
commit
aeeaa7094d
1 changed files with 9 additions and 12 deletions
|
@ -36,6 +36,7 @@ class Contact < ActiveRecord::Base
|
||||||
validate :val_ident_valid_format?
|
validate :val_ident_valid_format?
|
||||||
validate :uniq_statuses?
|
validate :uniq_statuses?
|
||||||
validate :validate_html
|
validate :validate_html
|
||||||
|
validate :val_country_code
|
||||||
|
|
||||||
after_initialize do
|
after_initialize do
|
||||||
self.statuses = [] if statuses.nil?
|
self.statuses = [] if statuses.nil?
|
||||||
|
@ -43,7 +44,7 @@ class Contact < ActiveRecord::Base
|
||||||
self.ident_updated_at = Time.zone.now if new_record? && ident_updated_at.blank?
|
self.ident_updated_at = Time.zone.now if new_record? && ident_updated_at.blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
before_validation :val_upcase_country_code
|
before_validation :to_upcase_country_code
|
||||||
before_validation :val_prefix_code
|
before_validation :val_prefix_code
|
||||||
before_create :generate_auth_info
|
before_create :generate_auth_info
|
||||||
|
|
||||||
|
@ -346,18 +347,14 @@ class Contact < ActiveRecord::Base
|
||||||
destroy
|
destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
def val_upcase_country_code
|
def to_upcase_country_code
|
||||||
if code = Country.new(ident_country_code)
|
self.ident_country_code = ident_country_code.upcase if ident_country_code
|
||||||
self.ident_country_code = code.alpha2
|
self.country_code = country_code.upcase if country_code
|
||||||
else
|
end
|
||||||
errors.add(:ident, :invalid_country_code)
|
|
||||||
end if ident_country_code_changed? && ident_country_code.present?
|
|
||||||
|
|
||||||
if code = Country.new(country_code)
|
def val_country_code
|
||||||
self.country_code = code.alpha2
|
errors.add(:ident, :invalid_country_code) unless Country.new(ident_country_code)
|
||||||
else
|
errors.add(:ident, :invalid_country_code) unless Country.new(country_code)
|
||||||
errors.add(:country_code, :invalid_country_code)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def related_domain_descriptions
|
def related_domain_descriptions
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue