Commit 0c20ed400ea1adb9ac37e25a9d4529ee3b62c421
1 parent
9a5b65f2
Exists in
master
and in
29 other branches
ActionItem439: script that load the database updated
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2009 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
11 additions
and
2 deletions
Show diff stats
script/extract_sies_data.rb
... | ... | @@ -19,6 +19,11 @@ class Enterprise < ActiveRecord::Base |
19 | 19 | set_primary_key :id_sies |
20 | 20 | has_many :products, :foreign_key => 'V00', :conditions => "tipo = 'produto'" |
21 | 21 | has_many :input_products, :class_name => 'Product', :foreign_key => 'V00', :conditions => "tipo = 'insumo'" |
22 | + has_one :extra_data, :foreign_key => 'V00' | |
23 | +end | |
24 | + | |
25 | +class ExtraData < ActiveRecord::Base | |
26 | + set_table_name 'dados_extra' | |
22 | 27 | end |
23 | 28 | |
24 | 29 | class Product < ActiveRecord::Base |
... | ... | @@ -100,7 +105,11 @@ categories[#{cat.id}] = cat#{@seq}.id |
100 | 105 | :lat => #{ent.lat.inspect}, |
101 | 106 | :lng => #{ent.long.inspect}, |
102 | 107 | :geocode_precision => #{ent.geomodificou.inspect}, |
103 | - :data => { :id_sies => #{ent.id_sies.inspect} }, | |
108 | + :data => { | |
109 | + :id_sies => #{ent.id_sies.inspect}, | |
110 | + :foundation_year => #{ent.extra_data.ANO.inspect}, | |
111 | + :cnpj => #{ent.extra_data.CNPJ.inspect} | |
112 | + }, | |
104 | 113 | :contact_email => #{email.inspect}, |
105 | 114 | :categories => [cities[#{ent.id_cidade}]]}, |
106 | 115 | [#{ent.products.map{|p| "{ :name => #{p.category.nome.inspect} , :product_category_id => categories[#{p.category.id}] }"}.join(', ')}], | ... | ... |
script/fbes_populate_helper.rb
... | ... | @@ -52,7 +52,7 @@ require File.dirname(__FILE__) + '/../config/environment' |
52 | 52 | count += 1 |
53 | 53 | end |
54 | 54 | data[:identifier] = ident |
55 | - ent = Enterprise.create!({:environment => Environment.default}.merge(data)) | |
55 | + ent = Enterprise.create!({:environment => Environment.default}.merge(data), :enabled => false) | |
56 | 56 | products.each do |p| |
57 | 57 | ent.products.create!(p) unless ent.products.find(:first, :conditions => p) |
58 | 58 | end | ... | ... |