Commit c0055ee1776542367c5bf71731b6caa526d39220

Authored by AntonioTerceiro
1 parent 2d8b231f

ActionItem93: adding mroe sample data



git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1037 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing 1 changed file with 45 additions and 18 deletions   Show diff stats
script/anhetegua
@@ -2,7 +2,11 @@ @@ -2,7 +2,11 @@
2 require File.dirname(__FILE__) + '/../config/environment' 2 require File.dirname(__FILE__) + '/../config/environment'
3 3
4 Environment.default.categories.destroy_all 4 Environment.default.categories.destroy_all
5 -Organization.destroy_all 5 +User.destroy_all
  6 +Profile.destroy_all
  7 +Role.destroy_all
  8 +RoleAssignment.destroy_all
  9 +Category.destroy_all
6 10
7 def new_category(parent, name, color = nil) 11 def new_category(parent, name, color = nil)
8 category = Environment.default.categories.build(:name => name, :display_color => color, :parent_id => (parent ? parent.id: nil)) 12 category = Environment.default.categories.build(:name => name, :display_color => color, :parent_id => (parent ? parent.id: nil))
@@ -21,9 +25,14 @@ def new_validator(region, name, identifier) @@ -21,9 +25,14 @@ def new_validator(region, name, identifier)
21 org.validation_info = ValidationInfo.new(:validation_methodology => 'some methodology we don\'t care about') 25 org.validation_info = ValidationInfo.new(:validation_methodology => 'some methodology we don\'t care about')
22 org.save! 26 org.save!
23 region.validators << org 27 region.validators << org
  28 + region.save!
24 org 29 org
25 end 30 end
26 31
  32 +def new_member(org, person)
  33 + org.affiliate()
  34 +end
  35 +
27 tematicas = new_category(nil, 'Temáticas', 1) 36 tematicas = new_category(nil, 'Temáticas', 1)
28 new_category(tematicas, 'Finanças Solidárias') 37 new_category(tematicas, 'Finanças Solidárias')
29 new_category(tematicas, 'Marco Legal') 38 new_category(tematicas, 'Marco Legal')
@@ -39,35 +48,53 @@ new_category(cadeias, &#39;Algodão&#39;) @@ -39,35 +48,53 @@ new_category(cadeias, &#39;Algodão&#39;)
39 new_category(cadeias, 'Tecnologia de Informação') 48 new_category(cadeias, 'Tecnologia de Informação')
40 49
41 # validators 50 # validators
42 -new_validator(ba, "Colivre", 'colivre')  
43 -new_validator(ba, "Forum Baiano de Economia Solidaraia", 'ecosolbahia') 51 +colivre = new_validator(ba, "Colivre", 'colivre')
  52 +forum_bahia = new_validator(ba, "Forum Baiano de Economia Solidaraia", 'ecosolbahia')
44 53
45 -new_validator(df, 'Caritas', 'caritas')  
46 -new_validator(df, 'Forum Brasileiro de Economia Solidaria', 'fbes') 54 +caritas = new_validator(df, 'Caritas', 'caritas')
  55 +fbes = new_validator(df, 'Forum Brasileiro de Economia Solidaria', 'fbes')
47 56
48 -new_validator(rs, 'Associacao Software Livre.Org', 'asl')  
49 -new_validator(rs, 'Forum Gaucho de Economia Solidaria', 'ecosolrs') 57 +asl = new_validator(rs, 'Associacao Software Livre.Org', 'asl')
  58 +forum_rs = new_validator(rs, 'Forum Gaucho de Economia Solidaria', 'ecosolrs')
50 59
51 -Profile.destroy_all  
52 -# Profile for exibition of homepage and creations of sytem articles such as about and accessibility  
53 -noosfero = Profile.create!(:name => 'noosfero', :identifier => 'noosfero')  
54 -  
55 -Role.destroy_all  
56 # Role for own things 60 # Role for own things
57 owner_role = Role.create!(:name => 'owner', :permissions => ['edit_profile', 'destroy_profile', 'manage_memberships', 'post_content', 'edit_profile_design']) 61 owner_role = Role.create!(:name => 'owner', :permissions => ['edit_profile', 'destroy_profile', 'manage_memberships', 'post_content', 'edit_profile_design'])
58 62
59 # root user of the system, admin_role for him, the assignment of the role for him and the ownership of the system homepage 63 # root user of the system, admin_role for him, the assignment of the role for him and the ownership of the system homepage
60 -User.destroy_all  
61 root = User.create!(:login => 'root', :email => 'root@noosfero.org', :password => 'root', :password_confirmation => 'root').person 64 root = User.create!(:login => 'root', :email => 'root@noosfero.org', :password => 'root', :password_confirmation => 'root').person
62 admin_role = Role.create!(:name => 'admin', :permissions => ['view_environment_admin_panel','edit_environment_features', 'edit_environment_design', 'manage_environment_categories', 'manage_environment_roles', 'manage_environment_validators']) 65 admin_role = Role.create!(:name => 'admin', :permissions => ['view_environment_admin_panel','edit_environment_features', 'edit_environment_design', 'manage_environment_categories', 'manage_environment_roles', 'manage_environment_validators'])
63 66
64 -RoleAssignment.destroy_all  
65 RoleAssignment.create!(:accessor => root, :role => admin_role, :resource => Environment.default) 67 RoleAssignment.create!(:accessor => root, :role => admin_role, :resource => Environment.default)
66 -RoleAssignment.create!(:accessor => root, :role => owner_role, :resource => noosfero)  
67 68
68 # Sample user and sample enterprise owned by him 69 # Sample user and sample enterprise owned by him
69 -ze= User.create!(:login => 'ze', :email => 'ze@localhost.localdomain', :password => 'test', :password_confirmation => 'test').person  
70 -Enterprise.destroy_all 70 +ze = User.create!(:login => 'ze', :email => 'ze@localhost.localdomain', :password => 'test', :password_confirmation => 'test').person
71 empa = Enterprise.create!(:name => 'Empreendimento A', :identifier => 'empreendimento_a') 71 empa = Enterprise.create!(:name => 'Empreendimento A', :identifier => 'empreendimento_a')
72 -RoleAssignment.create!(:accessor => ze, :role => owner_role, :resource => empa) 72 +
  73 +empa.affiliate(ze, owner_role)
  74 +colivre.affiliate(ze, owner_role)
  75 +
  76 +
  77 +produtos = ProductCategory.create!(:name => 'Produtos', :environment => Environment.default, :display_color => 4)
  78 +
  79 +alimentacao = ProductCategory.new(:name => 'Alimentação', :environment => Environment.default, :parent => produtos); alimentacao.save!
  80 +
  81 +vegetais = ProductCategory.new(:name => 'Vegetais', :environment => Environment.default, :parent => alimentacao); vegetais.save!
  82 +
  83 +feijao = ProductCategory.new(:name => 'Feijão', :environment => Environment.default, :parent => vegetais); feijao.save!
  84 +
  85 +arroz = ProductCategory.new(:name => 'Arroz', :environment => Environment.default, :parent => vegetais); arroz.save!
  86 +
  87 +batata = ProductCategory.new(:name => 'Batata', :environment => Environment.default, :parent => vegetais); batata.save!
  88 +
  89 +carnes = ProductCategory.new(:name => 'Carnes', :environment => Environment.default, :parent => alimentacao); carnes.save!
  90 +
  91 +boi = ProductCategory.new(:name => 'Boi', :environment => Environment.default, :parent => carnes); boi.save!
  92 +
  93 +frango = ProductCategory.new(:name => 'Frango', :environment => Environment.default, :parent => carnes)
  94 +
  95 +vestuario = ProductCategory.new(:name => 'Vestuário', :environment => Environment.default, :parent => produtos); vestuario.save!
  96 +
  97 +camisetas = ProductCategory.new(:name => 'Camisetas', :environment => Environment.default, :parent => vestuario); camisetas.save!
  98 +
  99 +calcas = ProductCategory.new(:name => 'Calças', :environment => Environment.default, :parent => vestuario); calcas.save!
73 100