Add countries gem

This commit is contained in:
Martin Lensment 2015-02-02 11:29:48 +02:00
parent 864c451a61
commit 6aaf89593e
5 changed files with 17 additions and 5 deletions

View file

@ -52,7 +52,7 @@ gem 'daemons', '~> 1.1.9' # process delayed jobs
gem 'newrelic_rpm', '~> 3.9.9.275' gem 'newrelic_rpm', '~> 3.9.9.275'
# country listing # country listing
# gem 'countries', '~> 0.10.0' gem 'countries', '~> 0.10.0'
group :development do group :development do
# dev tools # dev tools

View file

@ -106,6 +106,9 @@ GEM
coffee-script-source coffee-script-source
execjs execjs
coffee-script-source (1.8.0) coffee-script-source (1.8.0)
countries (0.10.0)
currencies (~> 0.4.2)
currencies (0.4.2)
daemons (1.1.9) daemons (1.1.9)
database_cleaner (1.3.0) database_cleaner (1.3.0)
debug_inspector (0.0.2) debug_inspector (0.0.2)
@ -439,6 +442,7 @@ DEPENDENCIES
cancancan (~> 1.9.2) cancancan (~> 1.9.2)
capybara (~> 2.4.1) capybara (~> 2.4.1)
coffee-rails (~> 4.1.0) coffee-rails (~> 4.1.0)
countries (~> 0.10.0)
daemons (~> 1.1.9) daemons (~> 1.1.9)
database_cleaner (~> 1.3.0) database_cleaner (~> 1.3.0)
delayed_job_active_record (~> 4.0.3) delayed_job_active_record (~> 4.0.3)

View file

@ -8,10 +8,13 @@ class Address < ActiveRecord::Base
] ]
belongs_to :contact belongs_to :contact
belongs_to :country_deprecated, foreign_key: "country_id"
has_paper_trail class_name: 'AddressVersion' has_paper_trail class_name: 'AddressVersion'
def country
Country.new(country_code)
end
class << self class << self
# def validate_postal_info_types(parsed_frame) # def validate_postal_info_types(parsed_frame)
# errors, used = [], [] # errors, used = [], []

View file

@ -1,5 +1,4 @@
class Registrar < ActiveRecord::Base class Registrar < ActiveRecord::Base
belongs_to :country_deprecated, foreign_key: "country_id"
has_many :domains, dependent: :restrict_with_error has_many :domains, dependent: :restrict_with_error
has_many :contacts, dependent: :restrict_with_error has_many :contacts, dependent: :restrict_with_error
has_many :api_users, dependent: :restrict_with_error has_many :api_users, dependent: :restrict_with_error
@ -23,6 +22,10 @@ class Registrar < ActiveRecord::Base
name name
end end
def country
Country.new(country_code)
end
class << self class << self
def search_by_query(query) def search_by_query(query)
res = search(name_or_reg_no_cont: query).result res = search(name_or_reg_no_cont: query).result

View file

@ -6,8 +6,6 @@ class User < ActiveRecord::Base
# After activisation, system should require to change temp password. # After activisation, system should require to change temp password.
# TODO: Estonian id validation # TODO: Estonian id validation
belongs_to :country_deprecated, foreign_key: "country_id"
validates :username, :password, presence: true validates :username, :password, presence: true
validates :identity_code, uniqueness: true, allow_blank: true validates :identity_code, uniqueness: true, allow_blank: true
validates :identity_code, presence: true, if: -> { country.iso == 'EE' } validates :identity_code, presence: true, if: -> { country.iso == 'EE' }
@ -21,6 +19,10 @@ class User < ActiveRecord::Base
username username
end end
def country
Country.new(country_code)
end
private private
def validate_identity_code def validate_identity_code