Commit 0c65465a2f1027d640b46cb1684f538d57f761bd

Authored by AntonioTerceiro
1 parent 88946687

ActionItem93: sample data



git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1041 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing 1 changed file with 34 additions and 15 deletions   Show diff stats
script/anhetegua
... ... @@ -7,6 +7,7 @@ Profile.destroy_all
7 7 Role.destroy_all
8 8 RoleAssignment.destroy_all
9 9 Category.destroy_all
  10 +Product.destroy_all
10 11  
11 12 def new_category(parent, name, color = nil)
12 13 category = Environment.default.categories.build(:name => name, :display_color => color, :parent_id => (parent ? parent.id: nil))
... ... @@ -20,8 +21,8 @@ def new_region(parent, name, color = nil)
20 21 region
21 22 end
22 23  
23   -def new_validator(region, name, identifier)
24   - org = Organization.new(:name => name, :identifier => identifier)
  24 +def new_validator(region, name, identifier, klass = Organization)
  25 + org = klass.new(:name => name, :identifier => identifier)
25 26 org.validation_info = ValidationInfo.new(:validation_methodology => 'some methodology we don\'t care about')
26 27 org.save!
27 28 region.validators << org
... ... @@ -48,7 +49,7 @@ new_category(cadeias, &#39;Algodão&#39;)
48 49 new_category(cadeias, 'Tecnologia de Informação')
49 50  
50 51 # validators
51   -colivre = new_validator(ba, "Colivre", 'colivre')
  52 +colivre = new_validator(ba, "Colivre", 'colivre', Enterprise)
52 53 forum_bahia = new_validator(ba, "Forum Baiano de Economia Solidaraia", 'ecosolbahia')
53 54  
54 55 caritas = new_validator(df, 'Caritas', 'caritas')
... ... @@ -74,27 +75,45 @@ empa.affiliate(ze, owner_role)
74 75 colivre.affiliate(ze, owner_role)
75 76  
76 77  
77   -produtos = ProductCategory.create!(:name => 'Produtos', :environment => Environment.default, :display_color => 4)
  78 +# product categories
  79 +produtos = ProductCategory.create!(:name => 'Produtos/Serviços', :environment => Environment.default, :display_color => 4)
78 80  
79   -alimentacao = ProductCategory.new(:name => 'Alimentação', :environment => Environment.default, :parent => produtos); alimentacao.save!
  81 +alimentacao = ProductCategory.create!(:name => 'Alimentação', :environment => Environment.default, :parent => produtos)
  82 +vegetais = ProductCategory.create!(:name => 'Vegetais', :environment => Environment.default, :parent => alimentacao)
80 83  
81   -vegetais = ProductCategory.new(:name => 'Vegetais', :environment => Environment.default, :parent => alimentacao); vegetais.save!
  84 +feijao = ProductCategory.create!(:name => 'Feijão', :environment => Environment.default, :parent => vegetais)
82 85  
83   -feijao = ProductCategory.new(:name => 'Feijão', :environment => Environment.default, :parent => vegetais); feijao.save!
  86 +arroz = ProductCategory.create!(:name => 'Arroz', :environment => Environment.default, :parent => vegetais)
84 87  
85   -arroz = ProductCategory.new(:name => 'Arroz', :environment => Environment.default, :parent => vegetais); arroz.save!
  88 +batata = ProductCategory.create!(:name => 'Batata', :environment => Environment.default, :parent => vegetais)
86 89  
87   -batata = ProductCategory.new(:name => 'Batata', :environment => Environment.default, :parent => vegetais); batata.save!
  90 +carnes = ProductCategory.create!(:name => 'Carnes', :environment => Environment.default, :parent => alimentacao)
88 91  
89   -carnes = ProductCategory.new(:name => 'Carnes', :environment => Environment.default, :parent => alimentacao); carnes.save!
  92 +boi = ProductCategory.create!(:name => 'Boi', :environment => Environment.default, :parent => carnes)
90 93  
91   -boi = ProductCategory.new(:name => 'Boi', :environment => Environment.default, :parent => carnes); boi.save!
  94 +frango = ProductCategory.create!(:name => 'Frango', :environment => Environment.default, :parent => carnes)
92 95  
93   -frango = ProductCategory.new(:name => 'Frango', :environment => Environment.default, :parent => carnes)
  96 +vestuario = ProductCategory.create!(:name => 'Vestuário', :environment => Environment.default, :parent => produtos)
94 97  
95   -vestuario = ProductCategory.new(:name => 'Vestuário', :environment => Environment.default, :parent => produtos); vestuario.save!
  98 +camisetas = ProductCategory.create!(:name => 'Camisetas', :environment => Environment.default, :parent => vestuario)
96 99  
97   -camisetas = ProductCategory.new(:name => 'Camisetas', :environment => Environment.default, :parent => vestuario); camisetas.save!
  100 +calcas = ProductCategory.create!(:name => 'Calças', :environment => Environment.default, :parent => vestuario)
98 101  
99   -calcas = ProductCategory.new(:name => 'Calças', :environment => Environment.default, :parent => vestuario); calcas.save!
  102 +software_livre = ProductCategory.create!(:name => 'Software Livre', :environment => Environment.default, :parent => produtos)
100 103  
  104 +desenv = ProductCategory.create!(:name => 'Desenvolvimento', :environment => Environment.default, :parent => software_livre)
  105 +capacitacao = ProductCategory.create!(:name => 'Capacitação', :environment => Environment.default, :parent => software_livre)
  106 +admin_de_sistemas = ProductCategory.create!(:name => 'Administração de sistemas', :environment => Environment.default, :parent => software_livre)
  107 +arte_digital = ProductCategory.create!(:name => 'Arte Digital', :environment => Environment.default, :parent => software_livre)
  108 +
  109 +
  110 +# actual products
  111 +
  112 +empa.products.build(:name => 'Feijão Mulatinho da Bahia', :product_category => feijao).save!
  113 +empa.products.build(:name => 'Arroz plantado lá em casa', :product_category => arroz).save!
  114 +empa.products.build(:name => 'Carne da vaca mimosa', :product_category => boi).save!
  115 +
  116 +colivre.products.build(:name => 'desenvolvimento de software livre', :product_category => desenv).save!
  117 +colivre.products.build(:name => 'capacitação em software livre', :product_category => capacitacao).save!
  118 +colivre.products.build(:name => 'arte digital', :product_category => arte_digital).save!
  119 +colivre.products.build(:name => 'instalação e manutenção de servidores', :product_category => admin_de_sistemas).save!
... ...