Commit 21b4f0bcce70ab380f8f4e5f8c38ff137fbb3059
1 parent
093c5317
Exists in
master
and in
28 other branches
Separating the sample data scripts a little more
Showing
4 changed files
with
120 additions
and
113 deletions
Show diff stats
app/models/environment.rb
... | ... | @@ -135,7 +135,8 @@ class Environment < ActiveRecord::Base |
135 | 135 | env.boxes[1].blocks << RecentDocumentsBlock.new |
136 | 136 | |
137 | 137 | # "right" area |
138 | - env.boxes[2].blocks << ProfileListBlock.new | |
138 | + env.boxes[2].blocks << CommunitiesBlock.new(:limit => 4) | |
139 | + env.boxes[2].blocks << PeopleBlock.new(:limit => 4) | |
139 | 140 | end |
140 | 141 | |
141 | 142 | # One Environment can be reached by many domains | ... | ... |
script/sample-data
... | ... | @@ -24,118 +24,7 @@ EOF |
24 | 24 | environment = Environment.create!(:name => 'Noosfero', :is_default => true, :description => DEFAULT_ENVIRONMENT_TEXT) unless (Environment.default) |
25 | 25 | end |
26 | 26 | |
27 | -places = [ | |
28 | - { :country=>'BR', :city=>'Salvador', | |
29 | - :lat=>-12.94032, :lng=>-38.58398 }, | |
30 | - { :country=>'BR', :city=>'São Paulo', | |
31 | - :lat=>-23.54894, :lng=>-46.63881 }, | |
32 | - { :country=>'BR', :city=>'Rio de Janeiro', | |
33 | - :lat=>-22.90353, :lng=>-43.20958 }, | |
34 | - { :country=>'AR', :city=>'Buenos Aires', | |
35 | - :lat=>-34.61088, :lng=>-58.39782 }, | |
36 | - { :country=>'AR', :city=>'Mar del Plata', | |
37 | - :lat=>-37.98317, :lng=>-57.59513 }, | |
38 | - { :country=>'MX', :city=>'Acapulco', | |
39 | - :lat=>16.86369, :lng=>-99.88151 }, | |
40 | - { :country=>'US', :city=>'Los Angeles', | |
41 | - :lat=>34.02307, :lng=>-118.24310 }, | |
42 | - { :country=>'IT', :city=>'Roma', | |
43 | - :lat=>41.89512, :lng=>12.48184 }, | |
44 | - { :country=>'IN', :city=>'Mumbai', | |
45 | - :lat=>19.01798, :lng=>72.85583 }, | |
46 | - { :country=>'CN', :city=>'Shanghai', | |
47 | - :lat=>31.23041, :lng=>121.47308 }, | |
48 | - { :country=>'JP', :city=>'Tokyo', | |
49 | - :lat=>35.68964, :lng=>139.69116 }, | |
50 | - { :country=>'FR', :city=>'Paris', | |
51 | - :lat=>48.85658, :lng=>2.351074 }, | |
52 | - { :country=>'BW', :city=>'Sowa', | |
53 | - :lat=>-20.56891, :lng=>26.22367 } | |
54 | -] | |
55 | - | |
56 | -people = [] | |
57 | - | |
58 | -NAMES = %w[ José João Antonio Paulo Maria Joana Paula Angela ] | |
59 | -SURNAMES = %w[ Silva Santos Abreu Oliveira Machado Bonfim ] | |
60 | -print "Creating users: " | |
61 | -for name in NAMES | |
62 | - for surname in SURNAMES | |
63 | - full_name = [name, surname].join(' ') | |
64 | - user = User.create!({ | |
65 | - :login => full_name.to_slug, | |
66 | - :email => full_name.to_slug + '@localhost.localdomain', | |
67 | - :password => 'test', | |
68 | - :password_confirmation => 'test', | |
69 | - :environment => environment, | |
70 | - }) | |
71 | - user.person.name = full_name | |
72 | - place = places[rand(places.length)] | |
73 | - user.person.data[:country] = place[:country] | |
74 | - user.person.city = place[:city] | |
75 | - user.person.lat = place[:lat] + (rand/100)-0.005 | |
76 | - user.person.lng = place[:lng] + (rand/100)-0.005 | |
77 | - user.person.save! | |
78 | - people << user.person | |
79 | - | |
80 | - print '.' | |
81 | - end | |
82 | -end | |
83 | -puts ' done!' | |
84 | - | |
85 | -print "Creating some friendships: " | |
86 | -rand(people.size * 3).times do | |
87 | - from = people.rand | |
88 | - to = people.rand | |
89 | - if from != to && !from.friends.include?(to) | |
90 | - AddFriend.create!(:requestor => to, :target => from).finish | |
91 | - end | |
92 | - print '.' | |
93 | -end | |
94 | -puts ' done!' | |
95 | - | |
96 | - | |
97 | -communities = [] | |
98 | -VERBS = ['Save', 'I like', 'Use'] | |
99 | -STUFF = ['Free Software', 'Organic food', 'the wales', 'the environment'] | |
100 | -print "Creating communities: " | |
101 | -for verb in VERBS | |
102 | - for stuff in STUFF | |
103 | - name = [verb, stuff].join(' ') | |
104 | - community = Community.create!(:name => name, :environment => environment) | |
105 | - communities << community | |
106 | - rand(10).times do | |
107 | - community.add_member(people.rand) | |
108 | - end | |
109 | - print '.' | |
110 | - end | |
111 | -end | |
112 | -puts ' done!' | |
113 | - | |
114 | -EVENTS = ['International Conference on %s', '%s day', '%s World Congress', '%s World Forum', '%s Summit', '%s Week'] | |
115 | -THEMES = ['Sustainability', 'Free Software', 'Climate Change', 'Environment', 'Agile Development', 'Solidarity Economy'] | |
116 | -print "Creating some events: " | |
117 | -for event in EVENTS | |
118 | - for theme in THEMES | |
119 | - Event.create!(:name => event % theme, :profile => communities.rand, :start_date => Date.today + (-30 + rand(60)).days) | |
120 | - print '.' | |
121 | - end | |
122 | -end | |
123 | -puts ' done!' | |
124 | - | |
125 | -ze = User.create!({ | |
126 | - :login => "ze", | |
127 | - :email => 'root@localhost.localdomain', | |
128 | - :password => 'test', | |
129 | - :password_confirmation => 'test', | |
130 | - :environment => environment, | |
131 | -}).person | |
132 | -environment.add_admin(ze) | |
133 | - | |
27 | +system('./script/sample-profiles') | |
134 | 28 | system('./script/sample-categories') |
135 | 29 | system('./script/sample-enterprises') |
136 | 30 | system('./script/sample-products') |
137 | - | |
138 | -# give admin rights for 'ze' in some enterprises | |
139 | -Enterprise.all.rand.add_admin(ze) | |
140 | -Enterprise.all.rand.add_admin(ze) | |
141 | -Enterprise.all.rand.add_admin(ze) | ... | ... |
script/sample-enterprises
... | ... | @@ -42,3 +42,9 @@ EnterpriseActivation.find(:all, :conditions => ['created_at > ?', start_time]).e |
42 | 42 | enterprise = activation.enterprise |
43 | 43 | puts [activation.code, enterprise.name, enterprise.foundation_year].join(';') |
44 | 44 | end |
45 | + | |
46 | +ze = Person['ze'] | |
47 | +# give admin rights for 'ze' in some enterprises | |
48 | +Enterprise.all.rand.add_admin(ze) | |
49 | +Enterprise.all.rand.add_admin(ze) | |
50 | +Enterprise.all.rand.add_admin(ze) | ... | ... |
... | ... | @@ -0,0 +1,111 @@ |
1 | +#!/usr/bin/env ruby | |
2 | +require File.dirname(__FILE__) + '/../config/environment' | |
3 | + | |
4 | +environment = Environment.default | |
5 | + | |
6 | +places = [ | |
7 | + { :country=>'BR', :city=>'Salvador', | |
8 | + :lat=>-12.94032, :lng=>-38.58398 }, | |
9 | + { :country=>'BR', :city=>'São Paulo', | |
10 | + :lat=>-23.54894, :lng=>-46.63881 }, | |
11 | + { :country=>'BR', :city=>'Rio de Janeiro', | |
12 | + :lat=>-22.90353, :lng=>-43.20958 }, | |
13 | + { :country=>'AR', :city=>'Buenos Aires', | |
14 | + :lat=>-34.61088, :lng=>-58.39782 }, | |
15 | + { :country=>'AR', :city=>'Mar del Plata', | |
16 | + :lat=>-37.98317, :lng=>-57.59513 }, | |
17 | + { :country=>'MX', :city=>'Acapulco', | |
18 | + :lat=>16.86369, :lng=>-99.88151 }, | |
19 | + { :country=>'US', :city=>'Los Angeles', | |
20 | + :lat=>34.02307, :lng=>-118.24310 }, | |
21 | + { :country=>'IT', :city=>'Roma', | |
22 | + :lat=>41.89512, :lng=>12.48184 }, | |
23 | + { :country=>'IN', :city=>'Mumbai', | |
24 | + :lat=>19.01798, :lng=>72.85583 }, | |
25 | + { :country=>'CN', :city=>'Shanghai', | |
26 | + :lat=>31.23041, :lng=>121.47308 }, | |
27 | + { :country=>'JP', :city=>'Tokyo', | |
28 | + :lat=>35.68964, :lng=>139.69116 }, | |
29 | + { :country=>'FR', :city=>'Paris', | |
30 | + :lat=>48.85658, :lng=>2.351074 }, | |
31 | + { :country=>'BW', :city=>'Sowa', | |
32 | + :lat=>-20.56891, :lng=>26.22367 } | |
33 | +] | |
34 | + | |
35 | +people = [] | |
36 | +NAMES = %w[ José João Antonio Paulo Maria Joana Paula Angela ] | |
37 | +SURNAMES = %w[ Silva Santos Abreu Oliveira Machado Bonfim ] | |
38 | +print "Creating users: " | |
39 | +for name in NAMES | |
40 | + for surname in SURNAMES | |
41 | + full_name = [name, surname].join(' ') | |
42 | + user = User.create!({ | |
43 | + :login => full_name.to_slug, | |
44 | + :email => full_name.to_slug + '@localhost.localdomain', | |
45 | + :password => 'test', | |
46 | + :password_confirmation => 'test', | |
47 | + :environment => environment, | |
48 | + }) | |
49 | + user.person.name = full_name | |
50 | + place = places[rand(places.length)] | |
51 | + user.person.data[:country] = place[:country] | |
52 | + user.person.city = place[:city] | |
53 | + user.person.lat = place[:lat] + (rand/100)-0.005 | |
54 | + user.person.lng = place[:lng] + (rand/100)-0.005 | |
55 | + user.person.save! | |
56 | + people << user.person | |
57 | + | |
58 | + print '.' | |
59 | + end | |
60 | +end | |
61 | +puts ' done!' | |
62 | + | |
63 | +print "Creating some friendships: " | |
64 | +rand(people.size * 3).times do | |
65 | + from = people.rand | |
66 | + to = people.rand | |
67 | + if from != to && !from.friends.include?(to) | |
68 | + AddFriend.create!(:requestor => to, :target => from).finish | |
69 | + end | |
70 | + print '.' | |
71 | +end | |
72 | +puts ' done!' | |
73 | + | |
74 | + | |
75 | +communities = [] | |
76 | +VERBS = ['Save', 'I like', 'Use'] | |
77 | +STUFF = ['Free Software', 'Organic food', 'the wales', 'the environment'] | |
78 | +print "Creating communities: " | |
79 | +for verb in VERBS | |
80 | + for stuff in STUFF | |
81 | + name = [verb, stuff].join(' ') | |
82 | + community = Community.create!(:name => name, :environment => environment) | |
83 | + communities << community | |
84 | + rand(10).times do | |
85 | + community.add_member(people.rand) | |
86 | + end | |
87 | + print '.' | |
88 | + end | |
89 | +end | |
90 | +puts ' done!' | |
91 | + | |
92 | +EVENTS = ['International Conference on %s', '%s day', '%s World Congress', '%s World Forum', '%s Summit', '%s Week'] | |
93 | +THEMES = ['Sustainability', 'Free Software', 'Climate Change', 'Environment', 'Agile Development', 'Solidarity Economy'] | |
94 | +print "Creating some events: " | |
95 | +for event in EVENTS | |
96 | + for theme in THEMES | |
97 | + Event.create!(:name => event % theme, :profile => communities.rand, :start_date => Date.today + (-30 + rand(60)).days) | |
98 | + print '.' | |
99 | + end | |
100 | +end | |
101 | +puts ' done!' | |
102 | + | |
103 | +ze = User.create!({ | |
104 | + :login => "ze", | |
105 | + :email => 'root@localhost.localdomain', | |
106 | + :password => 'test', | |
107 | + :password_confirmation => 'test', | |
108 | + :environment => environment, | |
109 | +}).person | |
110 | +environment.add_admin(ze) | |
111 | + | ... | ... |