Commit c364210148b2ee82c810ad65078585ad8edba6a2
1 parent
08bd677a
Exists in
master
and in
5 other branches
Remove useless tasks
Showing
2 changed files
with
3 additions
and
464 deletions
Show diff stats
lib/tasks/main_data.rake
... | ... | @@ -4,145 +4,15 @@ |
4 | 4 | namespace :main_data do |
5 | 5 | desc "Create the main community and its contents" |
6 | 6 | task :populate => :environment do |
7 | - Rake::Task["main_data:community"].invoke | |
8 | 7 | Rake::Task["templates:create:all"].invoke |
8 | + Rake::Task["software:create_licenses"].invoke | |
9 | + Rake::Task["software:create_categories"].invoke | |
10 | + Rake::Task["software:create_sample_softwares"].invoke | |
9 | 11 | end |
10 | 12 | |
11 | 13 | desc "Create the main community and its contents" |
12 | 14 | task :all => :environment do |
13 | - Rake::Task["main_data:destroy"].invoke | |
14 | 15 | Rake::Task["templates:destroy"].invoke |
15 | - Rake::Task["software:create_categories"].invoke | |
16 | 16 | Rake::Task["main_data:populate"].invoke |
17 | 17 | end |
18 | - | |
19 | - desc "Create the main community" | |
20 | - task :community => :environment do | |
21 | - Environment.all.each do |env| | |
22 | - if env.plugin_enabled?("MpogSoftware") or env.plugin_enabled?("SoftwareCommunitiesPlugin") | |
23 | - identifier = "spb" | |
24 | - community = Community.create!(:name => "SPB", :identifier => identifier) | |
25 | - community.layout_template = "leftbar" | |
26 | - | |
27 | - box1 = community.boxes.where(:position => 1).first | |
28 | - box2 = community.boxes.where(:position => 2).first | |
29 | - box3 = community.boxes.where(:position => 3).first | |
30 | - | |
31 | - box1.blocks.destroy_all | |
32 | - box2.blocks.destroy_all | |
33 | - box3.blocks.destroy_all | |
34 | - | |
35 | - community.save! | |
36 | - puts "SPB succesfully created!" | |
37 | - | |
38 | - main_block = MainBlock.new | |
39 | - main_block.position = 1 | |
40 | - main_block.save! | |
41 | - box1.blocks << main_block | |
42 | - box1.save! | |
43 | - puts "MainBlock successfully added to SPB!" | |
44 | - | |
45 | - generate_fixed_blocks(community) | |
46 | - | |
47 | - generate_article(community, Blog, {name: "Notícias", slug: "noticias", published: true, accept_comments: true, notify_comments: true, license_id: 1, body: "", accept_comments: false, posts_per_page: 5}, true) | |
48 | - generate_article(community, TinyMceArticle, {name: "Sobre o Portal", slug: "sobre-o-portal", published: true, accept_comments: false, notify_comments: true, license_id: 1, body: "", accept_comments: false}) | |
49 | - generate_article(community, TinyMceArticle, {name: "Publique seu software", slug: "publique-seu-software", published: true, accept_comments: false, notify_comments: true, license_id: 1, body: "", accept_comments: false}) | |
50 | - generate_article(community, TinyMceArticle, {name: "Inicie um projeto", slug: "inicie-um-projeto", published: true, accept_comments: false, notify_comments: true, license_id: 1, body: "", accept_comments: false}) | |
51 | - generate_article(community, TinyMceArticle, {name: "Entenda o que é", slug: "entenda-o-que-e", published: true, accept_comments: false, notify_comments: true, license_id: 1, body: "", accept_comments: false}) | |
52 | - generate_article(community, TinyMceArticle, {name: "Ajuda", slug: "ajuda", published: true, accept_comments: false, notify_comments: true, license_id: 1, body: "", accept_comments: false}) | |
53 | - generate_article(community, TinyMceArticle, {name: "Contato", slug: "contato", published: true, accept_comments: false, notify_comments: true, license_id: 1, body: "", accept_comments: false}) | |
54 | - end | |
55 | - end | |
56 | - end | |
57 | - | |
58 | - desc "Create the home page blocks" | |
59 | - task :home => :environment do | |
60 | - Environment.all.each do |env| | |
61 | - if env.plugin_enabled?("MpogSoftware") or env.plugin_enabled?("SoftwareCommunitiesPlugin") | |
62 | - identifier = "spb" | |
63 | - | |
64 | - box2 = env.boxes.where(:position => 2).first | |
65 | - box2.blocks.destroy_all | |
66 | - | |
67 | - generate_fixed_blocks(env) | |
68 | - end | |
69 | - end | |
70 | - end | |
71 | - | |
72 | - desc "Destroy all main content created by this namespace" | |
73 | - task :destroy => :environment do | |
74 | - Environment.all.each do |env| | |
75 | - if env.plugin_enabled?("MpogSoftware") or env.plugin_enabled?("SoftwareCommunitiesPlugin") | |
76 | - Community["spb"].destroy unless Community["spb"].nil? | |
77 | - puts "Main Community destoyed with success!" | |
78 | - end | |
79 | - end | |
80 | - end | |
81 | - | |
82 | - private | |
83 | - | |
84 | - def generate_article(software, klass, params, home_page = false) | |
85 | - article = klass.new(params) | |
86 | - article.body = params[:body] | |
87 | - | |
88 | - software.articles << article | |
89 | - if home_page | |
90 | - software.home_page = article | |
91 | - end | |
92 | - | |
93 | - software.save! | |
94 | - | |
95 | - puts "#{params[:name]} #{klass} successfully created!" | |
96 | - end | |
97 | - | |
98 | - def generate_fixed_blocks(profile) | |
99 | - identifier = "spb" | |
100 | - | |
101 | - box2 = profile.boxes.where(:position => 2).first | |
102 | - | |
103 | - first_link_list_block = LinkListBlock.new | |
104 | - first_link_list_block.position = 3 | |
105 | - first_link_list_block.display = "always" | |
106 | - first_link_list_block.title = "Portal do SPB" | |
107 | - first_link_list_block.fixed = true | |
108 | - first_link_list_block.save! | |
109 | - | |
110 | - first_link_list_block.links << {:icon => "no-icon", :name => "Sobre o Portal", :address => "/#{identifier}/sobre-o-portal", :target => "_self"} | |
111 | - first_link_list_block.links << {:icon => "no-icon", :name => "Notícias", :address => "/#{identifier}/noticias", :target => "_self"} | |
112 | - first_link_list_block.save! | |
113 | - box2.blocks << first_link_list_block | |
114 | - box2.save! | |
115 | - puts "First LinkListBlock successfully added to software!" | |
116 | - | |
117 | - second_link_list_block = LinkListBlock.new | |
118 | - second_link_list_block.position = 2 | |
119 | - second_link_list_block.display = "always" | |
120 | - second_link_list_block.title = "Software Público" | |
121 | - second_link_list_block.fixed = true | |
122 | - second_link_list_block.save! | |
123 | - | |
124 | - second_link_list_block.links << {:icon => "no-icon", :name => "Entenda o que é", :address => "/#{identifier}/entenda-o-que-e", :target => "_self"} | |
125 | - second_link_list_block.links << {:icon => "no-icon", :name => "Inicie um projeto", :address => "/#{identifier}/inicie-um-projeto", :target => "_self"} | |
126 | - second_link_list_block.links << {:icon => "no-icon", :name => "Publique seu software", :address => "/#{identifier}/publique-seu-software", :target => "_self"} | |
127 | - second_link_list_block.save! | |
128 | - box2.blocks << second_link_list_block | |
129 | - box2.save! | |
130 | - puts "Second LinkListBlock successfully added to software!" | |
131 | - | |
132 | - third_link_list_block = LinkListBlock.new | |
133 | - third_link_list_block.position = 1 | |
134 | - third_link_list_block.display = "always" | |
135 | - third_link_list_block.title = "" | |
136 | - third_link_list_block.fixed = true | |
137 | - third_link_list_block.save! | |
138 | - | |
139 | - third_link_list_block.links << {:icon => "no-icon", :name => "Catálogo de Software Público", :address => "/search/software_infos", :target => "_self"} | |
140 | - third_link_list_block.links << {:icon => "no-icon", :name => "Comunidades", :address => "/search/communities", :target => "_self"} | |
141 | - third_link_list_block.links << {:icon => "no-icon", :name => "Ajuda", :address => "/#{identifier}/ajuda", :target => "_self"} | |
142 | - | |
143 | - third_link_list_block.save! | |
144 | - box2.blocks << third_link_list_block | |
145 | - box2.save! | |
146 | - puts "Third LinkListBlock successfully added to software!" | |
147 | - end | |
148 | 18 | end | ... | ... |
lib/tasks/templates.rake
... | ... | @@ -6,10 +6,7 @@ namespace :templates do |
6 | 6 | |
7 | 7 | desc "Create new templates of software, intitution, person and community" |
8 | 8 | task :all => :environment do |
9 | - Rake::Task["templates:create:institution"].invoke | |
10 | 9 | Rake::Task["templates:create:software"].invoke |
11 | - Rake::Task["templates:create:people"].invoke | |
12 | - Rake::Task["templates:create:community"].invoke | |
13 | 10 | end |
14 | 11 | |
15 | 12 | desc "Create new templates of software" |
... | ... | @@ -24,350 +21,22 @@ namespace :templates do |
24 | 21 | |
25 | 22 | software.layout_template = "default" |
26 | 23 | software.is_template = true |
27 | - | |
28 | - box1 = software.boxes.where(:position => 1).first | |
29 | - box1.blocks.destroy_all | |
30 | - software.save! | |
31 | - | |
32 | - #This box is going to be used for fixed blocks | |
33 | - box2 = software.boxes.where(:position => 2).first | |
34 | - box2.blocks.destroy_all | |
35 | 24 | software.save! |
36 | 25 | |
37 | - box3 = software.boxes.where(:position => 3).first | |
38 | - box3.blocks.destroy_all | |
39 | - software.save! | |
40 | - puts "Software successfully created!" | |
41 | - | |
42 | - categories_block = CategoriesAndTagsBlock.new | |
43 | - categories_block.position = 4 | |
44 | - categories_block.display = "home_page_only" | |
45 | - categories_block.save! | |
46 | - box1.blocks << categories_block | |
47 | - box1.save! | |
48 | - puts "CategoriesAndTagsBlock successfully added to software!" | |
49 | - | |
50 | - main_block = MainBlock.new | |
51 | - main_block.position = 3 | |
52 | - main_block.save! | |
53 | - box1.blocks << main_block | |
54 | - box1.save! | |
55 | - | |
56 | - download_block = DownloadBlock.new | |
57 | - download_block.position = 2 | |
58 | - download_info = Hash.new | |
59 | - download_info[:name] = "Versão X.Y" | |
60 | - download_info[:link] = "#" | |
61 | - download_info[:software_description] = "(Windows X, Ubuntu Y, Debian Z)" | |
62 | - download_info[:version_news] = "#" | |
63 | - download_block.downloads << download_info | |
64 | - download_block.display = "home_page_only" | |
65 | - download_block.save! | |
66 | - box1.blocks << download_block | |
67 | - box1.save! | |
68 | - puts "DownloadBlock successfully added to software!" | |
69 | - | |
70 | - software_information_block = SoftwareInformationBlock.new | |
71 | - software_information_block.position = 1 | |
72 | - software_information_block.display = "home_page_only" | |
73 | - software_information_block.save! | |
74 | - box1.blocks << software_information_block | |
75 | - box1.save! | |
76 | - puts "SoftwareInformation successfully added to software!" | |
77 | - | |
78 | - puts "Software Main Box successfully created!" | |
79 | - | |
80 | - | |
81 | - members_block = MembersBlock.new | |
82 | - members_block.position = 6 | |
83 | - members_block.display = "except_home_page" | |
84 | - members_block.name = "" | |
85 | - members_block.address = "" | |
86 | - members_block.visible_role = "" | |
87 | - members_block.limit = 6 | |
88 | - members_block.prioritize_profiles_with_image = true | |
89 | - members_block.show_join_leave_button = false | |
90 | - members_block.title = "Equipe" | |
91 | - | |
92 | - members_block.save! | |
93 | - box3.blocks << members_block | |
94 | - box3.save! | |
95 | - | |
96 | - another_link_list_block = LinkListBlock.new | |
97 | - another_link_list_block.position = 5 | |
98 | - another_link_list_block.display = "always" | |
99 | - another_link_list_block.title = "Participe" | |
100 | - links = [{:icon => "", :name => "Lista de E-mails", :address => "http://beta.softwarepublico.gov.br/archives/thread/", :target => "_self"}, {:icon => "no-icon", :name => "Comunidade", :address => "/profile/{profile}", :target => "_self"}, {:icon => "", :name => "Blog", :address => "/{profile}/blog", :target => "_self"}, {:icon => "", :name => "Convide Amigos", :address => "/profile/{profile}/invite/friends", :target => "_self"}] | |
101 | - | |
102 | - another_link_list_block.save! | |
103 | - box3.blocks << another_link_list_block | |
104 | - another_link_list_block.update_attributes(:links => links) | |
105 | - box3.save! | |
106 | - puts "LinkListBlock successfully added to software!" | |
107 | - | |
108 | - | |
109 | - repository_block = RepositoryBlock.new | |
110 | - repository_block.position = 4 | |
111 | - repository_block.display = "always" | |
112 | - repository_block.title = "" | |
113 | - | |
114 | - repository_block.save! | |
115 | - box3.blocks << repository_block | |
116 | - box3.save! | |
117 | - puts "RepositoryBlock successfully added to software!" | |
118 | - | |
119 | - link_list_block = LinkListBlock.new | |
120 | - link_list_block.position = 3 | |
121 | - link_list_block.display = "always" | |
122 | - link_list_block.title = "Ajuda" | |
123 | - | |
124 | - link_list_block.save! | |
125 | - link_list_block.links << {:icon => "no-icon", :name => "Download de Versões", :address => "/{profile}/versoes", :target => "_self"} | |
126 | - link_list_block.links << {:icon => "", :name => "Pergutas Frequentes", :address => "/{profile}/perguntas-frequentes", :target => "_self"} | |
127 | - link_list_block.links << {:icon => "no-icon", :name => "README", :address => "/{profile}/versoes-estaveis", :target => "_self"} | |
128 | - link_list_block.links << {:icon => "", :name => "Como Instalar", :address => "/{profile}/tutorial-de-instalacao", :target => "_self"} | |
129 | - link_list_block.links << {:icon => "", :name => "Manuais", :address => "/{profile}/manuais-de-usuario", :target => "_self"} | |
130 | - link_list_block.save! | |
131 | - box3.blocks << link_list_block | |
132 | - box3.save! | |
133 | - puts "LinkListBlock successfully added to software!" | |
134 | - | |
135 | - profile_image_block = ProfileImageBlock.new | |
136 | - profile_image_block.position = 2 | |
137 | - profile_image_block.display = "except_home_page" | |
138 | - profile_image_block.show_name = false | |
139 | - profile_image_block.save! | |
140 | - | |
141 | - box3.blocks << profile_image_block | |
142 | - box3.save! | |
143 | - puts "ProfileImageBlock successfully added to software!" | |
144 | - | |
145 | - statistics_block = StatisticsBlock.new | |
146 | - statistics_block.position = 1 | |
147 | - statistics_block.display = "home_page_only" | |
148 | - statistics_block.save! | |
149 | - box3.blocks << statistics_block | |
150 | - box3.save! | |
151 | - puts "StatisticsBlock successfully added to software!" | |
152 | - puts "MembersBlock successfully added to software!" | |
153 | - puts "Software Box 3 successfully created!" | |
154 | - | |
155 | - generate_article(software, TinyMceArticle, {name: "Perguntas Frequentes", slug: "perguntas-frequentes", published: true, accept_comments: true, notify_comments: true, license_id: 1, body: "<h3 style=\"text-align: justify;\">Pergunta 1</h3>\r\n<ul>\r\n<li>Resposta: Resposta para a pergunta 1.</li>\r\n</ul>\r\n<p> </p>\r\n<h3>Pergunta 2</h3>\r\n<ul>\r\n<li>Resposta: Resposta para a pergunta 2.</li>\r\n</ul>\r\n<p> </p>\r\n<h3 style=\"text-align: justify;\">Pergunta 3</h3>\r\n<ul>\r\n<li style=\"text-align: justify;\">Resposta: Resposta para a pergunta 3.</li>\r\n</ul>"}) | |
156 | - | |
157 | - generate_article(software, Folder, {name: "Manuais de Usuário", published: true, accept_comments: false, notify_comments: true, license_id: 1, body: "Pasta destinada para manuais de uso do Software"}) | |
158 | - | |
159 | - generate_article(software, Folder, {name: "Versões Estáveis", slug: "versoes-estaveis", published: true, accept_comments: false, notify_comments: true, license_id: 1, body: "Pasta com os pacotes para download das versões existentes do Software."}) | |
160 | - | |
161 | - generate_article(software, TinyMceArticle, {name: "Tutorial de Instalação", body: "<h2>Introdução</h2>\r\n<p>Texto introdutório à página de instalação. Caso tenha-se uma documento específico que possa ser redundante com esta página, remova está página e mantenha apenas o documento. Neste caso, referencie-o adequadamente na página principal do seu software.</p>\r\n<h2>Requisitos</h2>\r\n<p>Texto identificando as dependências e requisitos necessários para a realização da instalação do Software.</p>\r\n<p>Para demonstrar comandos através de terminais utilize a seguinte formatação:</p>\r\n<table style=\"height: 25px; border-color: #000000; background-color: #e7bef7;\" width=\"461\">\r\n\r\n<tr>\r\n<td>\r\n<pre><code><em>$ sudo apt-get install example</em></code></pre>\r\n</td>\r\n</tr>\r\n\r\n</table>\r\n<h2>Passos para instalação</h2>\r\n<p>Crie quantos tópicos forem necessários para melhor explicar a instalação</p>\r\n<h2>Configuração</h2>\r\n<p>Explique todas as configurações necessários para configurar adequadamente outros serviços complementares e do próprio Software.</p>\r\n<h2>Teste da instalação</h2>\r\n<p>Explique os passos para testar se a instalação foi realizada com sucesso.</p>", license_id: 1}) | |
162 | - | |
163 | - generate_article(software, TinyMceArticle, {name: "Versões", body: "<p>Texto com detalhamento das mudanças que cada versão do software introduziu. Sugere-se que os arquivos aqui linkados sejam colocados dentro da pasta <a href=\"/software/versoes-estaveis\">Versões Estáveis</a>.</p>\r\n<hr />\r\n<h2> Versão X.Y.C</h2>\r\n<p>Download da <a title=\"Link para arquivo da versão\" href=\"#\">nova versão X.Y.C</a></p>\r\n<ul>\r\n<li>Nova funcionalidade 1</li>\r\n<li>Nova funcionalidade 2</li>\r\n<li>Novo bug resolvido 1</li>\r\n<li>Novo bug resolvido 2</li>\r\n</ul>\r\n<hr />\r\n<h2>Versão X.Y.B</h2>\r\n<p>Lançada <a title=\"Link para o arquivo da nova versão X.Y.B\" href=\"#\">nova versão X.Y.B</a></p>\r\n<ul>\r\n<li>Nova funcionalidade 1</li>\r\n<li>Nova funcionalidade 2</li>\r\n<li>Novo bug resolvido 1</li>\r\n<li>Novo bug resolvido 2</li>\r\n</ul>\r\n<hr />\r\n<h2>Versão X.Y.A</h2>\r\n<p>Download da <a title=\"Link para o arquivo da nova versão X.Y.A\" href=\"#\">nova versão X.Y.A</a></p>\r\n<ul>\r\n<li>Nova funcionalidade 1</li>\r\n<li>Nova funcionalidade 2</li>\r\n<li>Novo bug resolvido 1</li>\r\n<li>Novo bug resolvido 2</li>\r\n</ul>", license_id: 1}) | |
164 | - | |
165 | - generate_article(software, TinyMceArticle, {name: "Sobre o #{software.name}", body: "<p>Texto com explicação detalhada sobre o Software. </p>\r\n<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</p>\r\n<p>Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque felis.</p>\r\n<p>Morbi in sem quis dui placerat ornare. Pellentesque odio nisi, euismod in, pharetra a, ultricies in, diam. Sed arcu. Cras consequat.</p>\r\n<p>Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsa</p>\r\n<hr />\r\n<h1>Requisitos Mínimos</h1>\r\n<p>Texto curto informativo sobre os requisitos mínimos do software. </p>\r\n<p>Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque felis. Morbi in sem quis dui placerat ornare. Pellentesque odio nisi, euismod in, pharetra a, ultricies in, diam. Sed arcu. Cras consequa.</p>\r\n<p>Maiores informações podem ser encontradas na <a href=\"/{profile}/tutorial-de-instalacao\">página de instalação</a>.</p>\r\n<hr />\r\n<h1>Novidades da versão X.Y</h1>\r\n<p>Texto informativo sobre as novidades da última versão estável do software. Listar aqui as principais funcionalidades em linhas gerais. Pode-se também ter um link para a página de versões do software, onde terá informações mais detalhadas.</p>\r\n<ul>\r\n<li>Detalhes de uma funcionalidade nova</li>\r\n<li>Detalhes de outra funcionalidade nova</li>\r\n<li>Detalhes sobre um bug corrigido</li>\r\n<li>Detalhes sobre mudanças na interface de usuário</li>\r\n</ul>", license_id: 1 }, true) | |
166 | - | |
167 | - generate_fixed_blocks(software) | |
168 | - | |
169 | 26 | puts "Software Template successfully created!" |
170 | 27 | end |
171 | 28 | end |
172 | 29 | end |
173 | - | |
174 | - desc "Create new templates of people" | |
175 | - task :people => :environment do | |
176 | - Environment.all.each do |env| | |
177 | - if env.plugin_enabled?("MpogSoftware") or env.plugin_enabled?("SoftwareCommunitiesPlugin") | |
178 | - person = Person.where(:identifier => "noosfero_person_template").first | |
179 | - | |
180 | - if person.nil? | |
181 | - password = SecureRandom.hex(6) | |
182 | - user = User.create!(:name => "People", :login => "people", :email => "person@template.noo", :password => password , :password_confirmation => password, :environment => env) | |
183 | - person = user.person | |
184 | - end | |
185 | - | |
186 | - person.layout_template = "leftbar" | |
187 | - person.is_template = true | |
188 | - | |
189 | - box1 = person.boxes.where(:position => 1).first | |
190 | - box1.blocks.destroy_all | |
191 | - person.save! | |
192 | - puts "Person successfully created!" | |
193 | - | |
194 | - if env.plugin_enabled?("GovUserPlugin") | |
195 | - institution_block = InstitutionsBlock.new | |
196 | - institution_block.position = 4 | |
197 | - institution_block.save! | |
198 | - box1.blocks << institution_block | |
199 | - box1.save! | |
200 | - puts "InstitutionBlock successfully added to person!" | |
201 | - end | |
202 | - | |
203 | - software_block = SoftwaresBlock.new | |
204 | - software_block.position = 2 | |
205 | - software_block.save! | |
206 | - box1.blocks << software_block | |
207 | - box1.save! | |
208 | - puts "SoftwaresBlock successfully added to person!" | |
209 | - | |
210 | - community_block = CommunitiesBlock.new | |
211 | - community_block.position = 3 | |
212 | - community_block.save! | |
213 | - box1.blocks << community_block | |
214 | - box1.save! | |
215 | - puts "CommunitiesBlock successfully added to person!" | |
216 | - | |
217 | - main_block = MainBlock.new | |
218 | - main_block.position = 1 | |
219 | - main_block.save! | |
220 | - box1.blocks << main_block | |
221 | - box1.save! | |
222 | - puts "MainBlock successfully added to person!" | |
223 | - end | |
224 | - end | |
225 | - end | |
226 | - | |
227 | - | |
228 | - desc "Create new templates of community" | |
229 | - task :community => :environment do | |
230 | - Environment.all.each do |env| | |
231 | - if env.plugin_enabled?("MpogSoftware") or env.plugin_enabled?("SoftwareCommunitiesPlugin") | |
232 | - puts "Community successfully created!" | |
233 | - end | |
234 | - end | |
235 | - end | |
236 | - | |
237 | - desc "Create new templates of intitution" | |
238 | - task :institution => :environment do | |
239 | - Environment.all.each do |env| | |
240 | - if env.plugin_enabled?("MpogSoftware") or env.plugin_enabled?("GovUserPlugin") | |
241 | - community = Community.create!(:name => "institution", :is_template => true, :moderated_articles => true, :environment => env) | |
242 | - community.layout_template = "leftbar" | |
243 | - | |
244 | - box2 = community.boxes.where(:position => 2).first | |
245 | - box1 = community.boxes.where(:position => 1).first | |
246 | - box3 = community.boxes.where(:position => 3).first | |
247 | - | |
248 | - box2.blocks.destroy_all | |
249 | - box1.blocks.destroy_all | |
250 | - box3.blocks.destroy_all | |
251 | - | |
252 | - community.save! | |
253 | - puts "Institution succesfully created!" | |
254 | - | |
255 | - members_block = MembersBlock.new | |
256 | - members_block.limit = 16 | |
257 | - members_block.prioritize_profiles_with_image = true | |
258 | - members_block.show_join_leave_button = false | |
259 | - members_block.display_user = "all" | |
260 | - members_block.language = "all" | |
261 | - members_block.display = "always" | |
262 | - members_block.position = 2 | |
263 | - members_block.save! | |
264 | - box1.blocks << members_block | |
265 | - box1.save! | |
266 | - puts "MembersBlock successfully added to institution!" | |
267 | - | |
268 | - main_block = MainBlock.new | |
269 | - main_block.position = 1 | |
270 | - main_block.save! | |
271 | - box1.blocks << main_block | |
272 | - box1.save! | |
273 | - puts "MainBlock successfully added to institution!" | |
274 | - | |
275 | - generate_fixed_blocks(community) | |
276 | - end | |
277 | - end | |
278 | - end | |
279 | 30 | end |
280 | 31 | |
281 | - | |
282 | 32 | desc "Destroy all templates created by this namespace" |
283 | 33 | task :destroy => :environment do |
284 | 34 | Environment.all.each do |env| |
285 | 35 | if env.plugin_enabled?("MpogSoftware") or env.plugin_enabled?("SoftwareCommunitiesPlugin") |
286 | - Community["institution"].destroy unless Community["institution"].nil? | |
287 | - puts "Institution template destoyed with success!" | |
288 | - | |
289 | 36 | Community["software"].destroy unless Community["software"].nil? |
290 | 37 | puts "Software template destoyed with success!" |
291 | - | |
292 | - user = User["people"] | |
293 | - if !user.nil? | |
294 | - user.person.destroy | |
295 | - user.destroy | |
296 | - puts "Person template destroyed with success!" | |
297 | - end | |
298 | 38 | end |
299 | 39 | end |
300 | 40 | end |
301 | 41 | |
302 | - private | |
303 | - | |
304 | - def generate_article(software, klass, params, home_page = false) | |
305 | - article = klass.new(params) | |
306 | - article.body = params[:body] | |
307 | - | |
308 | - software.articles << article | |
309 | - if home_page | |
310 | - software.home_page = article | |
311 | - end | |
312 | - | |
313 | - software.save! | |
314 | - | |
315 | - puts "#{params[:name]} #{klass} successfully created!" | |
316 | - end | |
317 | - | |
318 | - def generate_fixed_blocks(profile) | |
319 | - identifier = "spb" | |
320 | - | |
321 | - community = Community[identifier] | |
322 | - | |
323 | - if community | |
324 | - box2 = profile.boxes.where(:position => 2).first | |
325 | - | |
326 | - first_link_list_block = LinkListBlock.new | |
327 | - first_link_list_block.position = 3 | |
328 | - first_link_list_block.display = "always" | |
329 | - first_link_list_block.title = "Portal do SPB" | |
330 | - first_link_list_block.fixed = true | |
331 | - first_link_list_block.save! | |
332 | - | |
333 | - first_link_list_block.links << {:icon => "no-icon", :name => "Sobre o Portal", :address => "/#{identifier}/sobre-o-portal", :target => "_self"} | |
334 | - first_link_list_block.links << {:icon => "no-icon", :name => "Notícias", :address => "/#{identifier}/noticias", :target => "_self"} | |
335 | - first_link_list_block.save! | |
336 | - box2.blocks << first_link_list_block | |
337 | - box2.save! | |
338 | - puts "First LinkListBlock successfully added to software!" | |
339 | - | |
340 | - second_link_list_block = LinkListBlock.new | |
341 | - second_link_list_block.position = 2 | |
342 | - second_link_list_block.display = "always" | |
343 | - second_link_list_block.title = "Software Público" | |
344 | - second_link_list_block.fixed = true | |
345 | - second_link_list_block.save! | |
346 | - | |
347 | - second_link_list_block.links << {:icon => "no-icon", :name => "Entenda o que é", :address => "/#{identifier}/entenda-o-que-e", :target => "_self"} | |
348 | - second_link_list_block.links << {:icon => "no-icon", :name => "Inicie um projeto", :address => "/#{identifier}/inicie-um-projeto", :target => "_self"} | |
349 | - second_link_list_block.links << {:icon => "no-icon", :name => "Publique seu software", :address => "/#{identifier}/publique-seu-software", :target => "_self"} | |
350 | - second_link_list_block.save! | |
351 | - box2.blocks << second_link_list_block | |
352 | - box2.save! | |
353 | - puts "Second LinkListBlock successfully added to software!" | |
354 | - | |
355 | - third_link_list_block = LinkListBlock.new | |
356 | - third_link_list_block.position = 1 | |
357 | - third_link_list_block.display = "always" | |
358 | - third_link_list_block.title = "" | |
359 | - third_link_list_block.fixed = true | |
360 | - third_link_list_block.save! | |
361 | - | |
362 | - third_link_list_block.links << {:icon => "no-icon", :name => "Catálogo de Software Público", :address => "/search/software_infos", :target => "_self"} | |
363 | - third_link_list_block.links << {:icon => "no-icon", :name => "Comunidades", :address => "/search/communities", :target => "_self"} | |
364 | - | |
365 | - third_link_list_block.save! | |
366 | - box2.blocks << third_link_list_block | |
367 | - box2.save! | |
368 | - puts "Third LinkListBlock successfully added to software!" | |
369 | - else | |
370 | - puts "IMPOSSIBLE TO CREATE FIXED BLOCKS, THERE IS NO COMMUNITY CALLED SPB" | |
371 | - end | |
372 | - end | |
373 | 42 | end | ... | ... |