Commit a6410152b6396ad25b6b065187af928892e7870b
1 parent
5630acf4
Exists in
master
and in
29 other branches
ActionItem85: bli
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@784 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
68 additions
and
1 deletions
Show diff stats
... | ... | @@ -0,0 +1,67 @@ |
1 | +#!/usr/bin/env ruby | |
2 | +require File.dirname(__FILE__) + '/../config/environment' | |
3 | + | |
4 | +Environment.default.categories.destroy_all | |
5 | +Organization.destroy_all | |
6 | + | |
7 | +def new_category(parent, name, color = nil) | |
8 | + category = Environment.default.categories.build(:name => name, :display_color => color, :parent_id => (parent ? parent.id: nil)) | |
9 | + category.save! | |
10 | + category | |
11 | +end | |
12 | + | |
13 | +def new_region(parent, name, color = nil) | |
14 | + region = Environment.default.regions.build(:name => name, :display_color => color, :parent_id => (parent ? parent.id: nil)) | |
15 | + region.save! | |
16 | + region | |
17 | +end | |
18 | + | |
19 | +def new_validator(region, name, identifier) | |
20 | + org = Organization.new(:name => name, :identifier => identifier) | |
21 | + org.validation_info = ValidationInfo.new(:validation_methodology => 'some methodology we don\'t care about') | |
22 | + org.save! | |
23 | + region.validators << org | |
24 | + org | |
25 | +end | |
26 | + | |
27 | +tematicas = new_category(nil, 'Temáticas', 1) | |
28 | +new_category(tematicas, 'Finanças Solidárias') | |
29 | +new_category(tematicas, 'Marco Legal') | |
30 | +new_category(tematicas, 'Software Livre') | |
31 | + | |
32 | +territorios = new_region(nil, 'Territórios', 2) | |
33 | +ba = new_region(territorios, 'Bahia') | |
34 | +df = new_region(territorios, 'Distrito Federal') | |
35 | +rs = new_region(territorios, 'Rio Grande do Sul') | |
36 | + | |
37 | +cadeias = new_category(nil, 'Cadeias', 3) | |
38 | +new_category(cadeias, 'Algodão') | |
39 | +new_category(cadeias, 'Tecnologia de Informação') | |
40 | + | |
41 | +# validators | |
42 | +new_validator(ba, "Colivre", 'colivre') | |
43 | +new_validator(ba, "Forum Baiano de Economia Solidaraia", 'ecosolbahia') | |
44 | + | |
45 | +new_validator(df, 'Caritas', 'caritas') | |
46 | +new_validator(df, 'Forum Brasileiro de Economia Solidaria', 'fbes') | |
47 | + | |
48 | +new_validator(rs, 'Associacao Software Livre.Org', 'asl') | |
49 | +new_validator(rs, 'Forum Gaucho de Economia Solidaria', 'ecosolrs') | |
50 | + | |
51 | +# Profile for exibition of homepage and creations of sytem articles such as about and accessibility | |
52 | +noosfero = Profile.create!(:name => 'noosfero', :identifier => 'noosfero') | |
53 | + | |
54 | +# Role for own things | |
55 | +owner_role = Role.create!(:name => 'owner', :permissions => ['edit_profile', 'destroy_profile', 'manage_memberships', 'post_content', 'edit_profile_design']) | |
56 | + | |
57 | +# root user of the system, admin_role for him, the assignment of the role for him and the ownership of the system homepage | |
58 | +root = User.create!(:login => 'root', :email => 'root@noosfero.org', :password => 'root', :password_confirmation => 'root').person | |
59 | +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']) | |
60 | +RoleAssignment.create!(:accessor => root, :role => admin_role, :resource => Environment.default) | |
61 | +RoleAssignment.create!(:accessor => root, :role => owner_role, :resource => noosfero) | |
62 | + | |
63 | +# Sample user and sample enterprise owned by him | |
64 | +ze= User.create!(:login => 'ze', :email => 'ze@localhost.localdomain', :password => 'test', :password_confirmation => 'test').person | |
65 | +empa = Enterprise.create!(:name => 'Empreendimento A', :identifier => 'empreendimento_a') | |
66 | +RoleAssignment.create!(:accessor => ze, :role => owner_role, :resource => empa) | |
67 | + | ... | ... |
script/reset_db
... | ... | @@ -5,5 +5,5 @@ system "rm #{RAILS_ROOT}/tmp/*.db" |
5 | 5 | system "rm #{RAILS_ROOT}/db/*.db" |
6 | 6 | system "rake db:migrate VERSION=0" |
7 | 7 | system "rake db:migrate" |
8 | -system "ruby #{RAILS_ROOT}/script/anhetegua" | |
8 | +system "#{RAILS_ROOT}/script/anhetegua" | |
9 | 9 | system "rake db:test:prepare" | ... | ... |