Commit 36ad1dcfc4760bbf1fe0bca48b66f6f6dd3ee0a7
1 parent
3b47e32a
Exists in
master
and in
29 other branches
Removing unused scripts
- New script to create sample categories in database: script/sample-categories
Showing
10 changed files
with
125 additions
and
744 deletions
Show diff stats
script/anhetegua
... | ... | @@ -1,216 +0,0 @@ |
1 | -#!/usr/bin/env ruby | |
2 | -require File.dirname(__FILE__) + '/../config/environment' | |
3 | -require 'console_with_helpers' | |
4 | - | |
5 | -GetText.locale = 'pt_BR' | |
6 | - | |
7 | -User.destroy_all | |
8 | -Profile.destroy_all | |
9 | - | |
10 | -Category.destroy_all | |
11 | -Product.destroy_all | |
12 | -Article.destroy_all | |
13 | -Environment.destroy_all | |
14 | - | |
15 | -def new_category(parent, name, color = nil) | |
16 | - category = Environment.default.categories.build(:name => name, :display_color => color, :parent_id => (parent ? parent.id: nil), :display_in_menu => true) | |
17 | - category.save! | |
18 | - category | |
19 | -end | |
20 | - | |
21 | -def new_region(parent, name, color = nil) | |
22 | - region = Environment.default.regions.build(:name => name, :display_color => color, :parent_id => (parent ? parent.id: nil), :display_in_menu => true) | |
23 | - region.save! | |
24 | - region | |
25 | -end | |
26 | - | |
27 | -def new_state(parent, name) | |
28 | - State.create!(:name => name, :parent => parent, :environment => Environment.default) | |
29 | -end | |
30 | - | |
31 | -def new_validator(region, name, identifier, klass = Organization) | |
32 | - org = klass.new(:name => name, :identifier => identifier) | |
33 | - org.validation_info = ValidationInfo.new(:validation_methodology => 'some methodology we don\'t care about') | |
34 | - org.save! | |
35 | - region.validators << org | |
36 | - region.save! | |
37 | - org | |
38 | -end | |
39 | - | |
40 | -environment_description = <<-EOF | |
41 | -<h1> | |
42 | -Boas vindas ao Sistema FBES: | |
43 | -A Comunidade virtual das Redes de Economia Solidária! | |
44 | -</h1> | |
45 | - | |
46 | -<img src='/images/logo-anhetegua.png' style='float: right'/> | |
47 | - | |
48 | -<p> | |
49 | -O Sistema FBES é uma plataforma livre e colaborativa que visa contribuir para o fortalecimento das redes de economia solidária em todo o Brasil, facilitando os fluxos de produção, comercialização, troca e consumo solidários. Cadastre-se, divirta-se e navegue nessa outra economia! | |
50 | -</p> | |
51 | - | |
52 | -<p> | |
53 | -O menu superior é o principal instrumento de navegação: | |
54 | -</p> | |
55 | -<ul> | |
56 | - <li>Do lado esquerdo, estão os recortes. <strong>Temáticas</strong> reune os principais temas debatidos. <strong>Territórios</strong> limita sua navegação a um estado de sua escolha. <strong>Cadeias</strong> exibe apenas informação relacionada à cadeia produtiva de sua preferência. </li> | |
57 | - | |
58 | - <li>Do lado direito, estão as opções do usuário, bem como a nevegação por tipo de conteúdo. <strong>Busca</strong> permite que você procure conteúdo por palavras chave. <strong>Blogs</strong> te levará a ver blogs de outros usuário. <strong>Produtos</strong> permitirá nevegar pelos produtos ... etc. </li> | |
59 | -</ul> | |
60 | -EOF | |
61 | - | |
62 | - | |
63 | -env = Environment.create!(:name => 'Sistema FBES', :is_default => true, :description => environment_description) | |
64 | - | |
65 | -# on production (i.e. anhetegua demo site, use a real domain) | |
66 | -if ENV['RAILS_ENV'] == 'production' | |
67 | - domain = Domain.new(:name => 'ecosol.noosfero.com.br') | |
68 | - domain.owner = env | |
69 | - domain.save! | |
70 | -end | |
71 | - | |
72 | -tematicas = new_category(nil, 'Temáticas', 1) | |
73 | -new_category(tematicas, 'Formação') | |
74 | -new_category(tematicas, 'Produção, comercialização e consumo') | |
75 | -new_category(tematicas, 'Relações internacionais') | |
76 | -new_category(tematicas, 'Marco Legal') | |
77 | -new_category(tematicas, 'Finanças Solidárias') | |
78 | -new_category(tematicas, 'Comunicação') | |
79 | -new_category(tematicas, 'Políticas públicas') | |
80 | -new_category(tematicas, 'Organização do movimento') | |
81 | -new_category(tematicas, 'Software, cultura e conhecimentos livres') | |
82 | -new_category(tematicas, 'Agroecologia') | |
83 | -new_category(tematicas, 'Pesquisa e tecnologia') | |
84 | -new_category(tematicas, 'Comércio justo e solidário') | |
85 | -new_category(tematicas, 'Cultura') | |
86 | - | |
87 | -territorios = new_region(nil, 'Territórios', 2) | |
88 | -nacional = new_region(territorios, 'Nacional') | |
89 | -internacional = new_region(territorios, 'Internacional') | |
90 | -centro_oeste = new_region(nacional, 'Região Centro-Oeste') | |
91 | -mt = new_state(centro_oeste, 'Mato Grosso') | |
92 | -ms = new_state(centro_oeste, 'Mato Grosso do Sul') | |
93 | -go = new_state(centro_oeste, 'Goiás') | |
94 | -df = new_state(centro_oeste, 'Distrito Federal') | |
95 | -nordeste = new_region(nacional, 'Região Nordeste') | |
96 | -al = new_state(nordeste, 'Alagoas') | |
97 | -ba = new_state(nordeste, 'Bahia') | |
98 | -ce = new_state(nordeste, 'Ceará') | |
99 | -ma = new_state(nordeste, 'Maranhão') | |
100 | -pb = new_state(nordeste, 'Paraíba') | |
101 | -pe = new_state(nordeste, 'Pernambuco') | |
102 | -pi = new_state(nordeste, 'Piauí') | |
103 | -rn = new_state(nordeste, 'Rio Grande do Norte') | |
104 | -se = new_state(nordeste, 'Sergipe') | |
105 | -norte = new_region(nacional, 'Região Norte') | |
106 | -ac = new_state(norte, 'Acre') | |
107 | -ap = new_state(norte, 'Amapá') | |
108 | -am = new_state(norte, 'Amazonas') | |
109 | -pa = new_state(norte, 'Pará') | |
110 | -ro = new_state(norte, 'Rondônia') | |
111 | -rr = new_state(norte, 'Roraima') | |
112 | -to = new_state(norte, 'Tocantins') | |
113 | -sudeste = new_region(nacional, 'Região Sudeste') | |
114 | -mg = new_state(sudeste, 'Minas Gerais') | |
115 | -sp = new_state(sudeste, 'São Paulo') | |
116 | -rj = new_state(sudeste, 'Rio de Janeiro') | |
117 | -es = new_state(sudeste, 'Espírito Santo') | |
118 | -sul = new_region(nacional, 'Região Sul') | |
119 | -pr = new_state(sul, 'Paraná') | |
120 | -rs = new_state(sul, 'Rio Grande do Sul') | |
121 | -sc = new_state(sul, 'Santa Catarina') | |
122 | - | |
123 | -cadeias = new_category(nil, 'Redes/Cadeias', 3) | |
124 | -new_category(cadeias, 'Agropecuária, extrativismo e pesca') | |
125 | -new_category(cadeias, 'Alimentação') | |
126 | -new_category(cadeias, 'Artesanato') | |
127 | -new_category(cadeias, 'Indústria') | |
128 | -new_category(cadeias, 'Confecção, fiação e tecelagem') | |
129 | -new_category(cadeias, 'Reciclagem') | |
130 | -new_category(cadeias, 'Turismo') | |
131 | -new_category(cadeias, 'Construção') | |
132 | -new_category(cadeias, 'Crédito e finanças') | |
133 | -new_category(cadeias, 'Saúde') | |
134 | -new_category(cadeias, 'Educação e formação') | |
135 | -new_category(cadeias, 'Limpeza e higiene') | |
136 | -new_category(cadeias, 'Cultura') | |
137 | -new_category(cadeias, 'Cadeia do mel') | |
138 | -new_category(cadeias, 'Cadeia do algodão agroecológico') | |
139 | -new_category(cadeias, 'Cadeia das sementes') | |
140 | -new_category(cadeias, 'Cadeia da fruta') | |
141 | - | |
142 | -# validators | |
143 | -colivre = new_validator(ba, "Colivre", 'colivre', Enterprise) | |
144 | -#forum_bahia = new_validator(ba, "Forum Baiano de Economia Solidaraia", 'ecosolbahia') | |
145 | -# | |
146 | -#caritas = new_validator(df, 'Caritas', 'caritas') | |
147 | -#fbes = new_validator(df, 'Forum Brasileiro de Economia Solidaria', 'fbes') | |
148 | -# | |
149 | -#asl = new_validator(rs, 'Associacao Software Livre.Org', 'asl') | |
150 | -#forum_rs = new_validator(rs, 'Forum Gaucho de Economia Solidaria', 'ecosolrs') | |
151 | - | |
152 | -# Role for own things | |
153 | -owner_role = Profile::Roles.admin(Environment.default.id) | |
154 | - | |
155 | -# Sample user and sample enterprise owned by him | |
156 | -ze = User.create!(:login => 'ze', :email => 'ze@localhost.localdomain', :password => 'test', :password_confirmation => 'test').person | |
157 | - | |
158 | -Environment.default.affiliate(ze, Environment::Roles.admin(Environment.default.id)) | |
159 | -empa = Enterprise.create!(:name => 'Cooperativa A', :identifier => 'coop_a') | |
160 | - | |
161 | -empa.affiliate(ze, owner_role) | |
162 | -colivre.affiliate(ze, owner_role) | |
163 | - | |
164 | -member_role = Profile::Roles.member(Environment.default.id) | |
165 | -moderator_role = Profile::Roles.moderator(Environment.default.id) | |
166 | - | |
167 | -# product categories | |
168 | -produtos = ProductCategory.create!(:name => 'Produtos', :environment => Environment.default) | |
169 | - | |
170 | -alimentacao = ProductCategory.create!(:name => 'Alimentação', :environment => Environment.default, :parent => produtos) | |
171 | -vegetais = ProductCategory.create!(:name => 'Vegetais', :environment => Environment.default, :parent => alimentacao) | |
172 | - | |
173 | -feijao = ProductCategory.create!(:name => 'Feijão', :environment => Environment.default, :parent => vegetais) | |
174 | - | |
175 | -arroz = ProductCategory.create!(:name => 'Arroz', :environment => Environment.default, :parent => vegetais) | |
176 | - | |
177 | -batata = ProductCategory.create!(:name => 'Batata', :environment => Environment.default, :parent => vegetais) | |
178 | - | |
179 | -carnes = ProductCategory.create!(:name => 'Carnes', :environment => Environment.default, :parent => alimentacao) | |
180 | - | |
181 | -boi = ProductCategory.create!(:name => 'Boi', :environment => Environment.default, :parent => carnes) | |
182 | - | |
183 | -frango = ProductCategory.create!(:name => 'Frango', :environment => Environment.default, :parent => carnes) | |
184 | - | |
185 | -vestuario = ProductCategory.create!(:name => 'Vestuário', :environment => Environment.default, :parent => produtos) | |
186 | - | |
187 | -camisetas = ProductCategory.create!(:name => 'Camisetas', :environment => Environment.default, :parent => vestuario) | |
188 | - | |
189 | -calcas = ProductCategory.create!(:name => 'Calças', :environment => Environment.default, :parent => vestuario) | |
190 | - | |
191 | -software_livre = ProductCategory.create!(:name => 'Software Livre', :environment => Environment.default, :parent => produtos) | |
192 | - | |
193 | -desenv = ProductCategory.create!(:name => 'Desenvolvimento', :environment => Environment.default, :parent => software_livre) | |
194 | -capacitacao = ProductCategory.create!(:name => 'Capacitação', :environment => Environment.default, :parent => software_livre) | |
195 | -admin_de_sistemas = ProductCategory.create!(:name => 'Administração de sistemas', :environment => Environment.default, :parent => software_livre) | |
196 | -arte_digital = ProductCategory.create!(:name => 'Arte Digital', :environment => Environment.default, :parent => software_livre) | |
197 | - | |
198 | - | |
199 | -# actual products | |
200 | - | |
201 | -empa.products.build(:name => 'Feijão Mulatinho da Bahia', :product_category => feijao).save! | |
202 | -empa.products.build(:name => 'Arroz plantado lá em casa', :product_category => arroz).save! | |
203 | -empa.products.build(:name => 'Carne da vaca mimosa', :product_category => boi).save! | |
204 | - | |
205 | -colivre.products.build(:name => 'desenvolvimento de software livre', :product_category => desenv).save! | |
206 | -colivre.products.build(:name => 'capacitação em software livre', :product_category => capacitacao).save! | |
207 | -colivre.products.build(:name => 'arte digital', :product_category => arte_digital).save! | |
208 | -colivre.products.build(:name => 'instalação e manutenção de servidores', :product_category => admin_de_sistemas).save! | |
209 | - | |
210 | -# creating sample communities | |
211 | -comm1 = Community.create!(:name => 'Outra Economia é Possível') | |
212 | -comm1.affiliate(ze, owner_role) | |
213 | - | |
214 | -comm2 = Community.create!(:name => 'Software Livre e Economia Solidária') | |
215 | -comm2.affiliate(ze, owner_role) | |
216 | - |
script/extract_sies_data.rb
... | ... | @@ -1,156 +0,0 @@ |
1 | -#!/usr/bin/ruby | |
2 | - | |
3 | -$LOAD_PATH.unshift('/usr/share/rails/activerecord/lib') | |
4 | -$LOAD_PATH.unshift('/usr/share/rails/activesupport/lib') | |
5 | - | |
6 | -require 'activerecord' | |
7 | -require 'active_support' | |
8 | -require File.dirname(__FILE__) + "/../" + 'lib/noosfero/core_ext/string.rb' | |
9 | - | |
10 | - | |
11 | -LIMIT = (ENV['DUMP_ALL'] ? nil : 10) | |
12 | -DUMP_ALL = LIMIT.nil? | |
13 | - | |
14 | -# To connect with the database that contains the data to be extracted cofigure it in the 'database_farejador.yml' with the name 'farejador' | |
15 | -ActiveRecord::Base.establish_connection(YAML::load(IO.read(File.dirname(__FILE__) + '/database_farejador.yml'))['farejador']) | |
16 | - | |
17 | -class Enterprise < ActiveRecord::Base | |
18 | - set_table_name 'cons_dadosbasicos' | |
19 | - set_primary_key :id_sies | |
20 | - has_many :products, :foreign_key => 'V00', :conditions => "tipo = 'produto'" | |
21 | - has_many :input_products, :class_name => 'Product', :foreign_key => 'V00', :conditions => "tipo = 'insumo'" | |
22 | - has_one :extra_data, :foreign_key => 'V00' | |
23 | -end | |
24 | - | |
25 | -class ExtraData < ActiveRecord::Base | |
26 | - set_table_name 'dados_extra' | |
27 | -end | |
28 | - | |
29 | -class Product < ActiveRecord::Base | |
30 | - set_table_name 'mapa_produtos' | |
31 | - belongs_to :category, :foreign_key => 'id_prod' | |
32 | -end | |
33 | - | |
34 | -class Category < ActiveRecord::Base | |
35 | - set_table_name 'lista_produtos' | |
36 | -end | |
37 | - | |
38 | -class Macroregion < ActiveRecord::Base | |
39 | - set_table_name 'macrorregioes' | |
40 | -end | |
41 | - | |
42 | -class State < ActiveRecord::Base | |
43 | - set_table_name 'estados' | |
44 | - set_primary_key :id_UF | |
45 | - has_one :macroregion, :foreign_key => 'UF' | |
46 | - | |
47 | - def cities | |
48 | - City.find(:all, :conditions => [ "id < 6000000 and id like '?%'", id_UF]) | |
49 | - end | |
50 | -end | |
51 | - | |
52 | -class City < ActiveRecord::Base | |
53 | - set_table_name 'cidades_ibge' | |
54 | -end | |
55 | - | |
56 | -class Dumper | |
57 | - def initialize | |
58 | - @seq = 0 | |
59 | - @seqs = {} | |
60 | - @r_seq = 0 | |
61 | - @r_seqs = {} | |
62 | - end | |
63 | - | |
64 | - def pretty(str, alt = nil) | |
65 | - if alt.nil? | |
66 | - str | |
67 | - else | |
68 | - str + ' (' + alt + ')' | |
69 | - end | |
70 | - end | |
71 | - | |
72 | - def dump_category(cat, parent = nil) | |
73 | - | |
74 | - @seqs[cat] = @seq | |
75 | - puts <<-EOF | |
76 | -cat#{@seq} = new_cat(#{pretty(cat.nome, cat.nome_alt).inspect}, #{parent ? 'cat' + @seqs[parent].to_s : 'nil' }) | |
77 | -categories[#{cat.id}] = cat#{@seq}.id | |
78 | - EOF | |
79 | - @seq += 1 | |
80 | - | |
81 | - Category.find(:all, :conditions => { :id_mae => cat.id }).each do |child| | |
82 | - dump_category(child, cat) if (DUMP_ALL || (@seq <= LIMIT)) | |
83 | - end | |
84 | - | |
85 | - end | |
86 | - | |
87 | - def dump_enterprise(ent) | |
88 | - email = nil | |
89 | - contato = nil | |
90 | - if (ent.corel =~ /@/) | |
91 | - email = ent.corel | |
92 | - else | |
93 | - contato = ent.corel | |
94 | - end | |
95 | - | |
96 | - endereco = ent.end | |
97 | - if ent.cep | |
98 | - endereco << " CEP: " << ent.cep | |
99 | - end | |
100 | - | |
101 | - puts <<-EOF | |
102 | -new_ent({ :name => #{ent.nome.inspect}, | |
103 | - :identifier => #{ent.nome.to_slug.inspect}, | |
104 | - :contact_phone => #{ent.tel.inspect}, | |
105 | - :address => #{endereco.inspect}, | |
106 | - :lat => #{ent.lat.inspect}, | |
107 | - :lng => #{ent.long.inspect}, | |
108 | - :geocode_precision => #{ent.geomodificou.inspect}, | |
109 | - :data => { | |
110 | - :id_sies => #{ent.id_sies.inspect} | |
111 | - }, | |
112 | - :contact_email => #{email.inspect}, | |
113 | - :foundation_year => #{ent.extra_data.ANO.inspect}, | |
114 | - :cnpj => #{ent.extra_data.CNPJ.inspect}, | |
115 | - :category_ids => [cities[#{ent.id_cidade}]].map(&:id) | |
116 | - }, | |
117 | - [#{ent.products.map{|p| "{ :name => #{p.category.nome.inspect} , :product_category_id => categories[#{p.category.id}] }"}.join(', ')}], | |
118 | - [#{ent.input_products.map{|p| "{ :product_category_id => categories[#{p.category.id}]}" }.join(', ')}]) | |
119 | -EOF | |
120 | - end | |
121 | - | |
122 | - def dump_city(city) | |
123 | - @r_seqs[city] = @r_seq | |
124 | - puts <<-EOF | |
125 | -city#{@r_seq} = new_region(#{city.cidade.inspect}, STATES[#{city.id.to_s[0..1]}], #{city.latitude}, #{city.longitude}) | |
126 | -cities[#{city.id}] = city#{@r_seq} | |
127 | - EOF | |
128 | - @r_seq += 1 | |
129 | - end | |
130 | - | |
131 | -end | |
132 | - | |
133 | -dumper = Dumper.new | |
134 | - | |
135 | -puts <<-EOF | |
136 | -#!/usr/bin/env ruby | |
137 | -require File.dirname(__FILE__) + '/../config/environment' | |
138 | -require File.dirname(__FILE__) + '/fbes_populate_helper.rb' | |
139 | - | |
140 | -GetText.locale = 'pt_BR' | |
141 | - | |
142 | -EOF | |
143 | - | |
144 | -puts "categories = {}" | |
145 | -Category.find(:all, :conditions => 'id_mae is null or id_mae = -1', :limit => LIMIT).each do |cat| | |
146 | - dumper.dump_category(cat, nil) | |
147 | -end | |
148 | - | |
149 | -puts "cities = {}" | |
150 | -City.find(:all, :limit => LIMIT).each do |city| | |
151 | - dumper.dump_city(city) | |
152 | -end | |
153 | - | |
154 | -Enterprise.find(:all, :limit => LIMIT).each do |ent| | |
155 | - dumper.dump_enterprise(ent) | |
156 | -end |
script/fbes_populate_helper.rb
... | ... | @@ -1,79 +0,0 @@ |
1 | -require File.dirname(__FILE__) + '/../config/environment' | |
2 | -require 'console_with_helpers' | |
3 | - | |
4 | -STATES = { | |
5 | - 12 => State.find_by_name('Acre'), | |
6 | - 27 => State.find_by_name('Alagoas'), | |
7 | - 13 => State.find_by_name('Amazonas'), | |
8 | - 16 => State.find_by_name('Amapá'), | |
9 | - 29 => State.find_by_name('Bahia'), | |
10 | - 23 => State.find_by_name('Ceará'), | |
11 | - 53 => State.find_by_name('Distrito Federal'), | |
12 | - 32 => State.find_by_name('Espírito Santo'), | |
13 | - 52 => State.find_by_name('Goiás'), | |
14 | - 21 => State.find_by_name('Maranhão'), | |
15 | - 31 => State.find_by_name('Minas Gerais'), | |
16 | - 50 => State.find_by_name('Mato Grosso do Sul'), | |
17 | - 51 => State.find_by_name('Mato Grosso'), | |
18 | - 15 => State.find_by_name('Pará'), | |
19 | - 25 => State.find_by_name('Paraíba'), | |
20 | - 26 => State.find_by_name('Pernambuco'), | |
21 | - 22 => State.find_by_name('Piauí'), | |
22 | - 41 => State.find_by_name('Paraná'), | |
23 | - 33 => State.find_by_name('Rio de Janeiro'), | |
24 | - 24 => State.find_by_name('Rio Grande do Norte'), | |
25 | - 11 => State.find_by_name('Rondônia'), | |
26 | - 14 => State.find_by_name('Roraima'), | |
27 | - 43 => State.find_by_name('Rio Grande do Sul'), | |
28 | - 42 => State.find_by_name('Santa Catarina'), | |
29 | - 28 => State.find_by_name('Sergipe'), | |
30 | - 35 => State.find_by_name('São Paulo'), | |
31 | - 17 => State.find_by_name('Tocantins'), | |
32 | -} | |
33 | - | |
34 | -COUNT = { | |
35 | - :enterprises => 0, | |
36 | - :regions => 0, | |
37 | - :categories => 0, | |
38 | -} | |
39 | - | |
40 | -$default_env = Environment.default | |
41 | -def step(what) | |
42 | - COUNT[what] += 1 | |
43 | - puts "#{what}: #{COUNT[what]}" | |
44 | -end | |
45 | - | |
46 | - def new_cat(name, parent = nil) | |
47 | - path = (parent ? parent.path + '/' : '') + name.to_slug | |
48 | - pc = Category.find_by_path(path) | |
49 | - pc = ProductCategory.create!(:name => name, :parent => parent, :environment => $default_env) unless pc | |
50 | - step(:categories) | |
51 | - pc | |
52 | - end | |
53 | - | |
54 | - def new_region(name, parent, lat, lng) | |
55 | - path = (parent ? parent.path + '/' : '') + name.to_slug | |
56 | - region = City.find_by_path(path) | |
57 | - region = City.create!(:name => name, :parent => parent, :lat => lat, :lng => lng, :environment => $default_env) unless region | |
58 | - step(:regions) | |
59 | - region | |
60 | - end | |
61 | - | |
62 | - def new_ent(data, products, consumptions) | |
63 | - count = 2 | |
64 | - ident = data[:identifier] | |
65 | - idents = Enterprise.find(:all, :conditions => ['identifier like ?', ident + '%']).map(&:identifier) | |
66 | - while idents.include?(ident) | |
67 | - ident = data[:identifier] + "-#{count}" | |
68 | - count += 1 | |
69 | - end | |
70 | - data[:identifier] = ident | |
71 | - ent = Enterprise.create!({:environment => $default_env, :enabled => false}.merge(data)) | |
72 | - products.each do |p| | |
73 | - ent.products.create(p) | |
74 | - end | |
75 | - consumptions.each do |c| | |
76 | - ent.consumptions.create(c) | |
77 | - end | |
78 | - step(:enterprises) | |
79 | - end |
script/fix_categories.rb
... | ... | @@ -1,21 +0,0 @@ |
1 | -require File.dirname(__FILE__) + '/fbes_populate_helper.rb' | |
2 | - | |
3 | -cat_produtos = ProductCategory.find_by_path('produtos') | |
4 | -cat_produtos_diversos = cat_produtos.children.create!(:name => 'Produtos diversos', :environment => cat_produtos.environment) | |
5 | -cat_servicos = ProductCategory.find_by_path('servicos') | |
6 | -cat_servicos_diversos = cat_servicos.children.find_by_name('Prestação de serviços diversos') | |
7 | -cat_diversos = ProductCategory.find_by_path('producao-e-servicos-diversos') | |
8 | - | |
9 | -cat_to_produtos = ProductCategory.top_level_for(Environment.default).select{|pc|![cat_diversos, cat_servicos, cat_produtos].include?(pc)} | |
10 | -cat_to_servicos = cat_diversos.children.select{|pc| ["Ação comunitária","Carro alugado","Carro de som","Distribuiçao de água","Em fase de implantação","Ilegível","Mensalidades","Pistas skate"].include?(pc.name)} | |
11 | -cat_to_produtos += (cat_diversos.children - cat_to_servicos) | |
12 | - | |
13 | -cat_to_produtos.each do |cat| | |
14 | - cat.parent = cat_produtos_diversos | |
15 | - cat.save! | |
16 | -end | |
17 | - | |
18 | -cat_to_produtos.each do |cat| | |
19 | - cat.parent = cat_servicos_diversos | |
20 | - cat.save! | |
21 | -end |
script/generate-image-thumb
... | ... | @@ -1,49 +0,0 @@ |
1 | -#!/bin/bash | |
2 | - | |
3 | -append="$1" | |
4 | -size="$2" | |
5 | - | |
6 | -if test \! -d public/thumbnails -o \! -d public/articles \ | |
7 | - -o -z "$append" -o -z "$size"; then | |
8 | - echo " | |
9 | - Rode esse script na raiz do Noosfero para criar um tipo de thumbnail | |
10 | - para as imagens-artigo. | |
11 | - | |
12 | - Uso: | |
13 | - $( basename "$0" ) <append-name> <size> | |
14 | - | |
15 | - <append-name>: será adicionado ao nome da imagem, antes da extensão. | |
16 | - Exemplo: | |
17 | - $( basename "$0" ) thumb '100x100>' | |
18 | - teste.jpg => teste_thumb.jpg | |
19 | - | |
20 | - <size>: deve ser um argumento gemométrico válido para o ImageMagick | |
21 | - http://imagemagick.org/script/command-line-processing.php#geometry | |
22 | - Exemplo: 200x200> redimensiona proporcionalmente apenas se a imagem | |
23 | - for maior que o espaço. | |
24 | - | |
25 | - Esse script varre o diretório de imagens-artigo | |
26 | - \"noosfero-path/public/articles/...\" e verifica se um arquivo de | |
27 | - mesmo nome e com <append-name> existe no diretório de thumbnails | |
28 | - \"noosfero-path/public/thumbnails/...\". Apenas se ele não existir | |
29 | - o mesmo será criado. Se deseja redimensionar um tipo já existente, | |
30 | - primeiro delete todas as ocorrencias. | |
31 | - " | |
32 | - exit 1 | |
33 | -fi | |
34 | - | |
35 | -cd public/articles | |
36 | -find * | egrep '\.(jpe?g|png|gif|xpm|svg|ico|pnm|tiff?)$' | | |
37 | -while read img; do | |
38 | - thumb="$( echo "../thumbnails/$img" | sed -r "s/(\.[^.]+)$/_$append\1/" )" | |
39 | - if test -e "$thumb"; then | |
40 | - echo " ok $img" | |
41 | - else | |
42 | - mkdir -p "$( dirname "$thumb" )" 2>- | |
43 | - echo " NOVO $img" | |
44 | - if ! convert "$img" -resize "$size" "$thumb"; then | |
45 | - echo -e "Deu Merda...\n" | |
46 | - fi | |
47 | - fi | |
48 | -done | |
49 | - |
script/generate-profile-big-images
... | ... | @@ -1,27 +0,0 @@ |
1 | -#!/bin/bash | |
2 | - | |
3 | -if ! cd public/images/0000; then | |
4 | - echo " | |
5 | - Rode esse script na raiz do Noosfero para ele redimensionar as | |
6 | - imagens dos usuarios. | |
7 | - " | |
8 | - exit 1 | |
9 | -fi | |
10 | - | |
11 | -echo " | |
12 | - Ok! We are on $(pwd) | |
13 | -" | |
14 | - | |
15 | -big='150x150' | |
16 | - | |
17 | -# Padrao: <nome>_<tamanho>.<ext> | |
18 | - | |
19 | -find . -type f | | |
20 | -grep --invert-match -E '_(thumb|portrait|minor|icon)\.' | | |
21 | -while read img; do | |
22 | - echo "Criando tamanho big ($big) para $img" | |
23 | - name=$( echo "$img" | sed 's/^\(.*\)\.[^\.]\+$/\1/' ) | |
24 | - ext=$( echo "$img" | sed 's/^.*\.\([^\.]\+\)$/\1/' ) | |
25 | - convert "$img" -resize $big "${name}_big.$ext" | |
26 | -done | |
27 | - |
script/release-v0.13.0-ecosol
... | ... | @@ -1,136 +0,0 @@ |
1 | -#!/bin/sh | |
2 | - | |
3 | -set -e | |
4 | - | |
5 | -if [ -z $RAILS_ENV ]; then | |
6 | - export RAILS_ENV=production | |
7 | -fi | |
8 | - | |
9 | -echo "Rails environment: $RAILS_ENV" | |
10 | - | |
11 | -echo 'Creating Big images...' | |
12 | -script/generate-profile-big-images | |
13 | - | |
14 | -echo 'Configurating templates...' | |
15 | -script/runner 'env = Environment.default; | |
16 | - e = Enterprise.create!(:name => "Inactive enterprise template", :identifier => env.name.to_slug + "_inactive_enterprise_template", :environment => env, :public_profile => false); | |
17 | - env.inactive_enterprise_template = e; | |
18 | - env.add_templates = [env.community_template, env.person_template, env.enterprise_template, env.inactive_enterprise_template]; | |
19 | - env.save!' | |
20 | - | |
21 | -echo 'Configurating template for active enterprises..' | |
22 | -script/runner 'env = Environment.default | |
23 | - template = env.enterprise_template | |
24 | - template.custom_footer = "<div align=center>{address} {- zip_code}<br/>{location}<br/>{<strong>Tel:</strong> contact_phone} {<strong>e-Mail:</strong> contact_email}<br/></div>" | |
25 | - template.custom_header = "<div align=center><h1>{name}</h1><br/></div>" | |
26 | - template.articles.destroy_all | |
27 | - homepage = TinyMceArticle.create!(:name => "Início", :body => "Esta é a página inicial do seu empreendimento", :profile => template, :accept_comments => false) | |
28 | - template.home_page = homepage | |
29 | - TinyMceArticle.create!(:name => "Quem somos", :body => "Aqui você pode falar sobre o seu empreendimento.", :profile => template, :accept_comments => false) | |
30 | - TinyMceArticle.create!(:name => "Pontos de venda", :body => "Aqui você pode falar sobre os seus pontos de venda.", :profile => template, :accept_comments => false) | |
31 | - template.layout_template = "leftbar" | |
32 | - main = template.boxes[0] | |
33 | - left = template.boxes[1] | |
34 | - main.blocks.destroy_all | |
35 | - left.blocks.destroy_all | |
36 | - left.blocks << ProfileImageBlock.new | |
37 | - left.blocks << LinkListBlock.new(:links => [ | |
38 | - {:name => "Início", :address => "/{profile}"}, | |
39 | - {:name => "Quem somos", :address => "/{profile}/quem-somos"}, | |
40 | - {:name => "Nossos produtos", :address => "/catalog/{profile}"}, | |
41 | - {:name => "Pontos de venda", :address => "/{profile}/pontos-de-venda"}, | |
42 | - {:name => "Fale conosco", :address => "/contact/{profile}/new"} | |
43 | - ]) | |
44 | - left.blocks << LocalizationBlock.new | |
45 | - main.blocks << MainBlock.new | |
46 | - template.save!' | |
47 | - | |
48 | -echo 'Configurating template for inactive enterprises..' | |
49 | -script/runner 'env = Environment.default | |
50 | - template = env.inactive_enterprise_template | |
51 | - template.articles.destroy_all | |
52 | - homepage = EnterpriseHomepage.create!(:name => "Início", :profile => template, :accept_comments => false) | |
53 | - template.home_page = homepage | |
54 | - template.layout_template = "leftbar" | |
55 | - main = template.boxes[0] | |
56 | - left = template.boxes[1] | |
57 | - main.blocks.destroy_all | |
58 | - left.blocks.destroy_all | |
59 | - left.blocks << [ProfileImageBlock.new, DisabledEnterpriseMessageBlock.new] | |
60 | - main.blocks << MainBlock.new | |
61 | - template.save!' | |
62 | - | |
63 | -echo 'Applying template for inactive enterprises' | |
64 | -script/apply-template 'inactive-enterprise' | |
65 | - | |
66 | -echo 'Applying template for active enterprises...' | |
67 | -script/apply-template 'active-enterprise' | |
68 | - | |
69 | -echo 'Enabling replace enterprise template when enable...' | |
70 | -script/runner 'env = Environment.default; | |
71 | - env.replace_enterprise_template_when_enable = true; | |
72 | - env.save!;' | |
73 | - | |
74 | -echo 'ATENCAO: Copie o tema (via scp) empreendimento-solidario para public/designs/themes/' | |
75 | -echo ' Nao esqueca de copiar o footer.rhtml do tema default' | |
76 | -echo ' (e pressione ENTER para continuar)' | |
77 | -read INPUT | |
78 | - | |
79 | -echo 'Applying empreendimento-solidario theme...' | |
80 | -script/runner "c = Enterprise.connection; | |
81 | - c.execute(\"UPDATE profiles SET theme = 'empreendimento-solidario' WHERE type = 'Enterprise'\") | |
82 | -" | |
83 | - | |
84 | -echo 'Configurating template for person...' | |
85 | -script/runner 'env = Environment.default | |
86 | - template = env.person_template | |
87 | - main = template.boxes[0] | |
88 | - left = template.boxes[1] | |
89 | - right = template.boxes[2] | |
90 | - main.blocks.destroy_all unless main.nil? | |
91 | - left.blocks.destroy_all unless left.nil? | |
92 | - right.blocks.destroy_all unless right.nil? | |
93 | - left.blocks << [ProfileInfoBlock.new, RecentDocumentsBlock.new, BlogArchivesBlock.new] | |
94 | - right.blocks << [FriendsBlock.new, EnterprisesBlock.new, CommunitiesBlock.new] | |
95 | - main.blocks << MainBlock.new | |
96 | - template.articles.destroy_all | |
97 | - template.articles << Blog.new(:name => "blog", :title => "Blog", :profile => template) | |
98 | - template.home_page = template.blog | |
99 | - template.save!' | |
100 | - | |
101 | -echo 'Applying template for person...' | |
102 | -script/apply-template 'person' | |
103 | - | |
104 | -echo 'Configurating template for community...' | |
105 | -script/runner 'env = Environment.default | |
106 | - template = env.community_template | |
107 | - main = template.boxes[0] | |
108 | - left = template.boxes[1] | |
109 | - right = template.boxes[2] | |
110 | - main.blocks.destroy_all unless main.nil? | |
111 | - left.blocks.destroy_all unless left.nil? | |
112 | - right.blocks.destroy_all unless right.nil? | |
113 | - left.blocks << [ProfileInfoBlock.new, RecentDocumentsBlock.new, BlogArchivesBlock.new] | |
114 | - right.blocks << MembersBlock.new | |
115 | - main.blocks << MainBlock.new | |
116 | - template.articles.destroy_all | |
117 | - template.articles << Blog.new(:name => "blog", :title => "Blog", :profile => template) | |
118 | - template.home_page = template.blog | |
119 | - template.save!' | |
120 | - | |
121 | -echo 'Applying template for communities...' | |
122 | -script/apply-template 'community' | |
123 | - | |
124 | -echo 'Schedule task-nitifier script...' | |
125 | -echo 'ATENCAO: Agende o script task-notifier no crontab para executar mensalmente' | |
126 | -echo ' Não esqueça de setar no environment.rb o ambiente para production' | |
127 | -echo ' (pressione ENTER para continuar)' | |
128 | -read INPUT | |
129 | - | |
130 | -echo 'Disabling CMS...' | |
131 | -script/runner 'env = Environment.default | |
132 | - env.enable("disable_cms") | |
133 | - env.save!' | |
134 | - | |
135 | -echo 'Publishing theme empreendimento-solidario...' | |
136 | -echo 'NOT IMPLEMENTED YET' |
script/resize-all-user-pics
... | ... | @@ -1,43 +0,0 @@ |
1 | -#!/bin/bash | |
2 | - | |
3 | -if ! cd public/images/0000; then | |
4 | - echo " | |
5 | - Rode esse script na raiz do Noosfero para ele redimensionar as | |
6 | - imagens dos usuarios. | |
7 | - " | |
8 | - exit 1 | |
9 | -fi | |
10 | - | |
11 | -echo " | |
12 | - Ok! We are on $(pwd) | |
13 | -" | |
14 | - | |
15 | -thumb='100x100' | |
16 | -portrait='64x64' | |
17 | -minor='50x50' | |
18 | -icon='20x20!' | |
19 | -lista='thumb | |
20 | -portrait | |
21 | -minor' | |
22 | -# Padrao: <nome>_<tamanho>.<ext> | |
23 | - | |
24 | -for s in $lista icon; do | |
25 | - echo "Deletando tamanho $s" | |
26 | - find . -name "*_$s.*" | xargs -L 1 -I{} rm '{}' | |
27 | -done | |
28 | - | |
29 | -find . -type f | | |
30 | -while read img; do | |
31 | - for s in $lista; do | |
32 | - sN=$( eval "echo \$$s" ) | |
33 | - echo "Criando tamanho $s ($sN) para $img" | |
34 | - name=$( echo "$img" | sed 's/^\(.*\)\.[^\.]\+$/\1/' ) | |
35 | - ext=$( echo "$img" | sed 's/^.*\.\([^\.]\+\)$/\1/' ) | |
36 | - convert "$img" -resize $sN "${name}_${s}.$ext" | |
37 | - done | |
38 | - echo "Criando tamanho icon ($icon) para $img" | |
39 | - convert -size $thumb xc:black -gravity Center \ | |
40 | - -draw "image over 0,0 0,0 '${name}_thumb.$ext'" \ | |
41 | - -resize $icon "${name}_icon.$ext" | |
42 | -done | |
43 | - |
... | ... | @@ -0,0 +1,125 @@ |
1 | +#!/usr/bin/env ruby | |
2 | +require File.dirname(__FILE__) + '/../config/environment' | |
3 | + | |
4 | +# tourn on autoflush | |
5 | +STDOUT.sync = true | |
6 | + | |
7 | +$environment_default = Environment.default | |
8 | + | |
9 | +def new_category(parent, name, color = nil) | |
10 | + print '.' | |
11 | + $environment_default.categories.create(:name => name, :display_color => color, :parent_id => (parent ? parent.id: nil), :display_in_menu => true) | |
12 | +end | |
13 | + | |
14 | +def new_region(parent, name, color = nil) | |
15 | + print '.' | |
16 | + $environment_default.regions.create(:name => name, :display_color => color, :parent_id => (parent ? parent.id: nil), :display_in_menu => true) | |
17 | +end | |
18 | + | |
19 | +def new_state(parent, name) | |
20 | + print '.' | |
21 | + State.create(:name => name, :parent => parent, :environment => $environment_default) | |
22 | +end | |
23 | + | |
24 | +def new_productcategory(parent, name) | |
25 | + print '.' | |
26 | + ProductCategory.create(:name => name, :environment => $environment_default, :parent => parent) | |
27 | +end | |
28 | + | |
29 | +def done | |
30 | + puts ' done!' | |
31 | +end | |
32 | + | |
33 | +print "Creating categories: " | |
34 | +tematicas = new_category(nil, 'Temáticas', 1) | |
35 | +new_category(tematicas, 'Formação') | |
36 | +new_category(tematicas, 'Produção, comercialização e consumo') | |
37 | +new_category(tematicas, 'Relações internacionais') | |
38 | +new_category(tematicas, 'Marco Legal') | |
39 | +new_category(tematicas, 'Finanças Solidárias') | |
40 | +new_category(tematicas, 'Comunicação') | |
41 | +new_category(tematicas, 'Políticas públicas') | |
42 | +new_category(tematicas, 'Organização do movimento') | |
43 | +new_category(tematicas, 'Software, cultura e conhecimentos livres') | |
44 | +new_category(tematicas, 'Agroecologia') | |
45 | +new_category(tematicas, 'Pesquisa e tecnologia') | |
46 | +new_category(tematicas, 'Comércio justo e solidário') | |
47 | +new_category(tematicas, 'Cultura') | |
48 | + | |
49 | +cadeias = new_category(nil, 'Redes/Cadeias', 3) | |
50 | +new_category(cadeias, 'Agropecuária, extrativismo e pesca') | |
51 | +new_category(cadeias, 'Alimentação') | |
52 | +new_category(cadeias, 'Artesanato') | |
53 | +new_category(cadeias, 'Indústria') | |
54 | +new_category(cadeias, 'Confecção, fiação e tecelagem') | |
55 | +new_category(cadeias, 'Reciclagem') | |
56 | +new_category(cadeias, 'Turismo') | |
57 | +new_category(cadeias, 'Construção') | |
58 | +new_category(cadeias, 'Crédito e finanças') | |
59 | +new_category(cadeias, 'Saúde') | |
60 | +new_category(cadeias, 'Educação e formação') | |
61 | +new_category(cadeias, 'Limpeza e higiene') | |
62 | +new_category(cadeias, 'Cultura') | |
63 | +new_category(cadeias, 'Cadeia do mel') | |
64 | +new_category(cadeias, 'Cadeia do algodão agroecológico') | |
65 | +new_category(cadeias, 'Cadeia das sementes') | |
66 | +new_category(cadeias, 'Cadeia da fruta') | |
67 | +done | |
68 | + | |
69 | +print "Creating regions: " | |
70 | +territorios = new_region(nil, 'Territórios', 2) | |
71 | +nacional = new_region(territorios, 'Nacional') | |
72 | +internacional = new_region(territorios, 'Internacional') | |
73 | +centro_oeste = new_region(nacional, 'Região Centro-Oeste') | |
74 | +mt = new_state(centro_oeste, 'Mato Grosso') | |
75 | +ms = new_state(centro_oeste, 'Mato Grosso do Sul') | |
76 | +go = new_state(centro_oeste, 'Goiás') | |
77 | +df = new_state(centro_oeste, 'Distrito Federal') | |
78 | +nordeste = new_region(nacional, 'Região Nordeste') | |
79 | +al = new_state(nordeste, 'Alagoas') | |
80 | +ba = new_state(nordeste, 'Bahia') | |
81 | +ce = new_state(nordeste, 'Ceará') | |
82 | +ma = new_state(nordeste, 'Maranhão') | |
83 | +pb = new_state(nordeste, 'Paraíba') | |
84 | +pe = new_state(nordeste, 'Pernambuco') | |
85 | +pi = new_state(nordeste, 'Piauí') | |
86 | +rn = new_state(nordeste, 'Rio Grande do Norte') | |
87 | +se = new_state(nordeste, 'Sergipe') | |
88 | +norte = new_region(nacional, 'Região Norte') | |
89 | +ac = new_state(norte, 'Acre') | |
90 | +ap = new_state(norte, 'Amapá') | |
91 | +am = new_state(norte, 'Amazonas') | |
92 | +pa = new_state(norte, 'Pará') | |
93 | +ro = new_state(norte, 'Rondônia') | |
94 | +rr = new_state(norte, 'Roraima') | |
95 | +to = new_state(norte, 'Tocantins') | |
96 | +sudeste = new_region(nacional, 'Região Sudeste') | |
97 | +mg = new_state(sudeste, 'Minas Gerais') | |
98 | +sp = new_state(sudeste, 'São Paulo') | |
99 | +rj = new_state(sudeste, 'Rio de Janeiro') | |
100 | +es = new_state(sudeste, 'Espírito Santo') | |
101 | +sul = new_region(nacional, 'Região Sul') | |
102 | +pr = new_state(sul, 'Paraná') | |
103 | +rs = new_state(sul, 'Rio Grande do Sul') | |
104 | +sc = new_state(sul, 'Santa Catarina') | |
105 | +done | |
106 | + | |
107 | +print "Creating product categories: " | |
108 | +produtos = new_productcategory(nil, 'Produtos') | |
109 | +alimentacao = new_productcategory(produtos, 'Alimentação') | |
110 | +vegetais = new_productcategory(alimentacao, 'Vegetais') | |
111 | +feijao = new_productcategory(vegetais, 'Feijão') | |
112 | +arroz = new_productcategory(vegetais, 'Arroz') | |
113 | +batata = new_productcategory(vegetais, 'Batata') | |
114 | +carnes = new_productcategory(alimentacao, 'Carnes') | |
115 | +boi = new_productcategory(carnes, 'Boi') | |
116 | +frango = new_productcategory(carnes, 'Frango') | |
117 | +vestuario = new_productcategory(produtos, 'Vestuário') | |
118 | +camisetas = new_productcategory(vestuario, 'Camisetas') | |
119 | +calcas = new_productcategory(vestuario, 'Calças') | |
120 | +software_livre = new_productcategory(produtos, 'Software Livre') | |
121 | +desenv = new_productcategory(software_livre, 'Desenvolvimento') | |
122 | +capacitacao = new_productcategory(software_livre, 'Capacitação') | |
123 | +admin_de_sistemas = new_productcategory(software_livre, 'Administração de sistemas') | |
124 | +arte_digital = new_productcategory(software_livre, 'Arte Digital') | |
125 | +done | ... | ... |
script/test-0.13
... | ... | @@ -1,17 +0,0 @@ |
1 | -#!/bin/sh | |
2 | - | |
3 | -set -e | |
4 | - | |
5 | -rm -f db/*.db | |
6 | -find public/images/[0-9]* -name \*big\* -delete | |
7 | -rake db:schema:load | |
8 | -rake db:populate | |
9 | -ruby script/anhetegua | |
10 | - | |
11 | -./script/runner ' | |
12 | - Enterprise["colivre"].home_page.update_attributes!(:body => "Content created by Colivre must not be lost") | |
13 | - | |
14 | - Enterprise.create!(:name => "Desabilitada", :identifier => "desabilitada", :enabled => false, :environment => Environment.default) | |
15 | -' | |
16 | - | |
17 | -RAILS_ENV=development script/release-v0.13.0-ecosol |