anhetegua
5.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/environment'
Environment.default.categories.destroy_all
User.destroy_all
Profile.destroy_all
Role.destroy_all
RoleAssignment.destroy_all
Category.destroy_all
Product.destroy_all
def new_category(parent, name, color = nil)
category = Environment.default.categories.build(:name => name, :display_color => color, :parent_id => (parent ? parent.id: nil))
category.save!
category
end
def new_region(parent, name, color = nil)
region = Environment.default.regions.build(:name => name, :display_color => color, :parent_id => (parent ? parent.id: nil))
region.save!
region
end
def new_validator(region, name, identifier, klass = Organization)
org = klass.new(:name => name, :identifier => identifier)
org.validation_info = ValidationInfo.new(:validation_methodology => 'some methodology we don\'t care about')
org.save!
region.validators << org
region.save!
org
end
def new_member(org, person)
org.affiliate()
end
tematicas = new_category(nil, 'Temáticas', 1)
new_category(tematicas, 'Finanças Solidárias')
new_category(tematicas, 'Marco Legal')
new_category(tematicas, 'Software Livre')
territorios = new_region(nil, 'Territórios', 2)
ba = new_region(territorios, 'Bahia')
df = new_region(territorios, 'Distrito Federal')
rs = new_region(territorios, 'Rio Grande do Sul')
cadeias = new_category(nil, 'Cadeias', 3)
new_category(cadeias, 'Algodão')
new_category(cadeias, 'Tecnologia de Informação')
# validators
colivre = new_validator(ba, "Colivre", 'colivre', Enterprise)
forum_bahia = new_validator(ba, "Forum Baiano de Economia Solidaraia", 'ecosolbahia')
caritas = new_validator(df, 'Caritas', 'caritas')
fbes = new_validator(df, 'Forum Brasileiro de Economia Solidaria', 'fbes')
asl = new_validator(rs, 'Associacao Software Livre.Org', 'asl')
forum_rs = new_validator(rs, 'Forum Gaucho de Economia Solidaria', 'ecosolrs')
# Role for own things
owner_role = Role.create!(:name => 'owner', :permissions => ['edit_profile', 'destroy_profile', 'manage_memberships', 'post_content', 'edit_profile_design'])
# root user of the system, admin_role for him, the assignment of the role for him and the ownership of the system homepage
root = User.create!(:login => 'root', :email => 'root@noosfero.org', :password => 'root', :password_confirmation => 'root').person
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'])
RoleAssignment.create!(:accessor => root, :role => admin_role, :resource => Environment.default)
# Sample user and sample enterprise owned by him
ze = User.create!(:login => 'ze', :email => 'ze@localhost.localdomain', :password => 'test', :password_confirmation => 'test').person
empa = Enterprise.create!(:name => 'Empreendimento A', :identifier => 'empreendimento_a')
empa.affiliate(ze, owner_role)
colivre.affiliate(ze, owner_role)
# product categories
produtos = ProductCategory.create!(:name => 'Produtos/Serviços', :environment => Environment.default, :display_color => 4)
alimentacao = ProductCategory.create!(:name => 'Alimentação', :environment => Environment.default, :parent => produtos)
vegetais = ProductCategory.create!(:name => 'Vegetais', :environment => Environment.default, :parent => alimentacao)
feijao = ProductCategory.create!(:name => 'Feijão', :environment => Environment.default, :parent => vegetais)
arroz = ProductCategory.create!(:name => 'Arroz', :environment => Environment.default, :parent => vegetais)
batata = ProductCategory.create!(:name => 'Batata', :environment => Environment.default, :parent => vegetais)
carnes = ProductCategory.create!(:name => 'Carnes', :environment => Environment.default, :parent => alimentacao)
boi = ProductCategory.create!(:name => 'Boi', :environment => Environment.default, :parent => carnes)
frango = ProductCategory.create!(:name => 'Frango', :environment => Environment.default, :parent => carnes)
vestuario = ProductCategory.create!(:name => 'Vestuário', :environment => Environment.default, :parent => produtos)
camisetas = ProductCategory.create!(:name => 'Camisetas', :environment => Environment.default, :parent => vestuario)
calcas = ProductCategory.create!(:name => 'Calças', :environment => Environment.default, :parent => vestuario)
software_livre = ProductCategory.create!(:name => 'Software Livre', :environment => Environment.default, :parent => produtos)
desenv = ProductCategory.create!(:name => 'Desenvolvimento', :environment => Environment.default, :parent => software_livre)
capacitacao = ProductCategory.create!(:name => 'Capacitação', :environment => Environment.default, :parent => software_livre)
admin_de_sistemas = ProductCategory.create!(:name => 'Administração de sistemas', :environment => Environment.default, :parent => software_livre)
arte_digital = ProductCategory.create!(:name => 'Arte Digital', :environment => Environment.default, :parent => software_livre)
# actual products
empa.products.build(:name => 'Feijão Mulatinho da Bahia', :product_category => feijao).save!
empa.products.build(:name => 'Arroz plantado lá em casa', :product_category => arroz).save!
empa.products.build(:name => 'Carne da vaca mimosa', :product_category => boi).save!
colivre.products.build(:name => 'desenvolvimento de software livre', :product_category => desenv).save!
colivre.products.build(:name => 'capacitação em software livre', :product_category => capacitacao).save!
colivre.products.build(:name => 'arte digital', :product_category => arte_digital).save!
colivre.products.build(:name => 'instalação e manutenção de servidores', :product_category => admin_de_sistemas).save!