From 12588c61d4b32bb32e207459a8731c5297f78fb9 Mon Sep 17 00:00:00 2001 From: MoisesMachado Date: Fri, 2 May 2008 15:31:49 +0000 Subject: [PATCH] ActionItem261: converted the enteprises identifier to an aceptable format and changed the identifier format to accept dots --- app/models/profile.rb | 2 +- script/extract_sies_data.rb | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/models/profile.rb b/app/models/profile.rb index 0fd5104..ad00ee3 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -36,7 +36,7 @@ class Profile < ActiveRecord::Base acts_as_having_settings :field => :data # Valid identifiers must match this format. - IDENTIFIER_FORMAT = /^[a-z][a-z0-9~]*([_-][a-z0-9~]+)*$/ + IDENTIFIER_FORMAT = /^[a-z][a-z0-9~.]*([_-][a-z0-9~.]+)*$/ # These names cannot be used as identifiers for Profiles RESERVED_IDENTIFIERS = %w[ diff --git a/script/extract_sies_data.rb b/script/extract_sies_data.rb index 2142afa..e2d3698 100644 --- a/script/extract_sies_data.rb +++ b/script/extract_sies_data.rb @@ -91,11 +91,21 @@ categories[#{cat.id}] = cat#{@seq}.id endereco << " CEP: " << ent.cep end - puts "new_ent({ :name => #{ent.nome.inspect}, :identifier => #{ent.nome.to_slug.inspect}, :contact_phone => #{ent.tel.inspect}, :address => #{endereco.inspect}, :lat => #{ent.lat.inspect}, :lng => #{ent.long.inspect}, :geocode_precision => #{ent.geomodificou.inspect}, :data => { :id_sies => #{ent.id_sies.inspect} }, :organization_info => OrganizationInfo.new(:contact_email => #{email.inspect}) }, #{ent.products.map{|p| { :name => p.category.nome , :product_category_id => p.category.id } }.inspect}, #{ent.input_products.map{|p| {:product_category_id => p.category.id} }.inspect})" + puts "new_ent({ :name => #{ent.nome.inspect}, + :identifier => #{ent.nome.to_slug.inspect}, + :contact_phone => #{ent.tel.inspect}, + :address => #{endereco.inspect}, + :lat => #{ent.lat.inspect}, + :lng => #{ent.long.inspect}, + :geocode_precision => #{ent.geomodificou.inspect}, + :data => { :id_sies => #{ent.id_sies.inspect} }, + :organization_info => OrganizationInfo.new(:contact_email => #{email.inspect}) }, + [#{ent.products.map{|p| "{ :name => #{p.category.nome.inspect} , :product_category_id => categories[#{p.category.id}] }"}.join(', ')}], + [#{ent.input_products.map{|p| "{ :product_category_id => categories[#{p.category.id}]}" }.join(', ')}])" end def dump_city(city) - puts "Region.create!(:name => #{city.cidade.inspect}, :parent => STATES[#{city.id.to_s[0..1]}], :lat => #{city.latitude}, :lng => #{city.longitude})" + puts "Region.create!(:name => #{city.cidade.inspect}, :parent => STATES[#{city.id.to_s[0..1]}], :lat => #{city.latitude}, :lng => #{city.longitude}, :environment => Environment.default)" end end -- libgit2 0.21.2