Commit c496d9c9a6d14a70cfcec6ffb32a83497d7fb75d
1 parent
a42676f5
Exists in
master
and in
5 other branches
Create fixed blocks for templates and main content
Signed-off-by: Arthur Del Esposte <arthurmde@gmail.com> Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
Showing
2 changed files
with
113 additions
and
41 deletions
Show diff stats
lib/tasks/main_data.rake
@@ -11,7 +11,8 @@ namespace :main_data do | @@ -11,7 +11,8 @@ namespace :main_data do | ||
11 | task :community => :environment do | 11 | task :community => :environment do |
12 | Environment.all.each do |env| | 12 | Environment.all.each do |env| |
13 | if env.plugin_enabled?("MpogSoftware") or env.plugin_enabled?("MpogSoftwarePlugin") | 13 | if env.plugin_enabled?("MpogSoftware") or env.plugin_enabled?("MpogSoftwarePlugin") |
14 | - community = Community.create!(:name => "SPB", :identifier => "spb") | 14 | + identifier = "spb" |
15 | + community = Community.create!(:name => "SPB", :identifier => identifier) | ||
15 | community.layout_template = "leftbar" | 16 | community.layout_template = "leftbar" |
16 | 17 | ||
17 | box1 = community.boxes.where(:position => 1).first | 18 | box1 = community.boxes.where(:position => 1).first |
@@ -32,46 +33,7 @@ namespace :main_data do | @@ -32,46 +33,7 @@ namespace :main_data do | ||
32 | box1.save! | 33 | box1.save! |
33 | puts "MainBlock successfully added to SPB!" | 34 | puts "MainBlock successfully added to SPB!" |
34 | 35 | ||
35 | - first_link_list_block = LinkListBlock.new | ||
36 | - first_link_list_block.position = 3 | ||
37 | - first_link_list_block.display = "always" | ||
38 | - first_link_list_block.title = "Portal do SPB" | ||
39 | - first_link_list_block.save! | ||
40 | - | ||
41 | - first_link_list_block.links << {:icon => "no-icon", :name => "Sobre o Portal", :address => "/{profile}/sobre-o-portal", :target => "_self"} | ||
42 | - first_link_list_block.links << {:icon => "no-icon", :name => "Notícias", :address => "/{profile}/noticias", :target => "_self"} | ||
43 | - first_link_list_block.save! | ||
44 | - box2.blocks << first_link_list_block | ||
45 | - box2.save! | ||
46 | - puts "First LinkListBlock successfully added to software!" | ||
47 | - | ||
48 | - second_link_list_block = LinkListBlock.new | ||
49 | - second_link_list_block.position = 2 | ||
50 | - second_link_list_block.display = "always" | ||
51 | - second_link_list_block.title = "Software Público" | ||
52 | - second_link_list_block.save! | ||
53 | - | ||
54 | - second_link_list_block.links << {:icon => "no-icon", :name => "Entenda o que é", :address => "/{profile}/entenda-o-que-e", :target => "_self"} | ||
55 | - second_link_list_block.links << {:icon => "no-icon", :name => "Inicie um projeto", :address => "/{profile}/inicie-um-projeto", :target => "_self"} | ||
56 | - second_link_list_block.links << {:icon => "no-icon", :name => "Publique seu software", :address => "/{profile}/publique-seu-software", :target => "_self"} | ||
57 | - second_link_list_block.save! | ||
58 | - box2.blocks << second_link_list_block | ||
59 | - box2.save! | ||
60 | - puts "Second LinkListBlock successfully added to software!" | ||
61 | - | ||
62 | - third_link_list_block = LinkListBlock.new | ||
63 | - third_link_list_block.position = 1 | ||
64 | - third_link_list_block.display = "always" | ||
65 | - third_link_list_block.title = "" | ||
66 | - third_link_list_block.save! | ||
67 | - | ||
68 | - third_link_list_block.links << {:icon => "no-icon", :name => "Catálogo de Software Público", :address => "#", :target => "_self"} | ||
69 | - third_link_list_block.links << {:icon => "no-icon", :name => "Comunidades", :address => "/search/communities", :target => "_self"} | ||
70 | - | ||
71 | - third_link_list_block.save! | ||
72 | - box2.blocks << third_link_list_block | ||
73 | - box2.save! | ||
74 | - puts "Third LinkListBlock successfully added to software!" | 36 | + generate_fixed_blocks(community) |
75 | 37 | ||
76 | 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}) | 38 | 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}) |
77 | 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}) | 39 | 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}) |
@@ -107,4 +69,54 @@ namespace :main_data do | @@ -107,4 +69,54 @@ namespace :main_data do | ||
107 | 69 | ||
108 | puts "#{params[:name]} #{klass} successfully created!" | 70 | puts "#{params[:name]} #{klass} successfully created!" |
109 | end | 71 | end |
72 | + | ||
73 | + def generate_fixed_blocks(profile) | ||
74 | + identifier = "spb" | ||
75 | + | ||
76 | + box2 = profile.boxes.where(:position => 2).first | ||
77 | + | ||
78 | + first_link_list_block = LinkListBlock.new | ||
79 | + first_link_list_block.position = 3 | ||
80 | + first_link_list_block.display = "always" | ||
81 | + first_link_list_block.title = "Portal do SPB" | ||
82 | + first_link_list_block.fixed = true | ||
83 | + first_link_list_block.save! | ||
84 | + | ||
85 | + first_link_list_block.links << {:icon => "no-icon", :name => "Sobre o Portal", :address => "/#{identifier}/sobre-o-portal", :target => "_self"} | ||
86 | + first_link_list_block.links << {:icon => "no-icon", :name => "Notícias", :address => "/#{identifier}/noticias", :target => "_self"} | ||
87 | + first_link_list_block.save! | ||
88 | + box2.blocks << first_link_list_block | ||
89 | + box2.save! | ||
90 | + puts "First LinkListBlock successfully added to software!" | ||
91 | + | ||
92 | + second_link_list_block = LinkListBlock.new | ||
93 | + second_link_list_block.position = 2 | ||
94 | + second_link_list_block.display = "always" | ||
95 | + second_link_list_block.title = "Software Público" | ||
96 | + second_link_list_block.fixed = true | ||
97 | + second_link_list_block.save! | ||
98 | + | ||
99 | + second_link_list_block.links << {:icon => "no-icon", :name => "Entenda o que é", :address => "/#{identifier}/entenda-o-que-e", :target => "_self"} | ||
100 | + second_link_list_block.links << {:icon => "no-icon", :name => "Inicie um projeto", :address => "/#{identifier}/inicie-um-projeto", :target => "_self"} | ||
101 | + second_link_list_block.links << {:icon => "no-icon", :name => "Publique seu software", :address => "/#{identifier}/publique-seu-software", :target => "_self"} | ||
102 | + second_link_list_block.save! | ||
103 | + box2.blocks << second_link_list_block | ||
104 | + box2.save! | ||
105 | + puts "Second LinkListBlock successfully added to software!" | ||
106 | + | ||
107 | + third_link_list_block = LinkListBlock.new | ||
108 | + third_link_list_block.position = 1 | ||
109 | + third_link_list_block.display = "always" | ||
110 | + third_link_list_block.title = "" | ||
111 | + third_link_list_block.fixed = true | ||
112 | + third_link_list_block.save! | ||
113 | + | ||
114 | + third_link_list_block.links << {:icon => "no-icon", :name => "Catálogo de Software Público", :address => "#", :target => "_self"} | ||
115 | + third_link_list_block.links << {:icon => "no-icon", :name => "Comunidades", :address => "/search/communities", :target => "_self"} | ||
116 | + | ||
117 | + third_link_list_block.save! | ||
118 | + box2.blocks << third_link_list_block | ||
119 | + box2.save! | ||
120 | + puts "Third LinkListBlock successfully added to software!" | ||
121 | + end | ||
110 | end | 122 | end |
lib/tasks/templates.rake
@@ -162,6 +162,8 @@ namespace :templates do | @@ -162,6 +162,8 @@ namespace :templates do | ||
162 | 162 | ||
163 | 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) | 163 | 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) |
164 | 164 | ||
165 | + generate_fixed_blocks(software) | ||
166 | + | ||
165 | puts "Software Template successfully created!" | 167 | puts "Software Template successfully created!" |
166 | end | 168 | end |
167 | end | 169 | end |
@@ -265,6 +267,8 @@ namespace :templates do | @@ -265,6 +267,8 @@ namespace :templates do | ||
265 | box1.blocks << main_block | 267 | box1.blocks << main_block |
266 | box1.save! | 268 | box1.save! |
267 | puts "MainBlock successfully added to institution!" | 269 | puts "MainBlock successfully added to institution!" |
270 | + | ||
271 | + generate_fixed_blocks(community) | ||
268 | end | 272 | end |
269 | end | 273 | end |
270 | end | 274 | end |
@@ -306,4 +310,60 @@ namespace :templates do | @@ -306,4 +310,60 @@ namespace :templates do | ||
306 | 310 | ||
307 | puts "#{params[:name]} #{klass} successfully created!" | 311 | puts "#{params[:name]} #{klass} successfully created!" |
308 | end | 312 | end |
313 | + | ||
314 | + def generate_fixed_blocks(profile) | ||
315 | + identifier = "spb" | ||
316 | + | ||
317 | + community = Community[identifier] | ||
318 | + | ||
319 | + if community | ||
320 | + box2 = profile.boxes.where(:position => 2).first | ||
321 | + | ||
322 | + first_link_list_block = LinkListBlock.new | ||
323 | + first_link_list_block.position = 3 | ||
324 | + first_link_list_block.display = "always" | ||
325 | + first_link_list_block.title = "Portal do SPB" | ||
326 | + first_link_list_block.fixed = true | ||
327 | + first_link_list_block.save! | ||
328 | + | ||
329 | + first_link_list_block.links << {:icon => "no-icon", :name => "Sobre o Portal", :address => "/#{identifier}/sobre-o-portal", :target => "_self"} | ||
330 | + first_link_list_block.links << {:icon => "no-icon", :name => "Notícias", :address => "/#{identifier}/noticias", :target => "_self"} | ||
331 | + first_link_list_block.save! | ||
332 | + box2.blocks << first_link_list_block | ||
333 | + box2.save! | ||
334 | + puts "First LinkListBlock successfully added to software!" | ||
335 | + | ||
336 | + second_link_list_block = LinkListBlock.new | ||
337 | + second_link_list_block.position = 2 | ||
338 | + second_link_list_block.display = "always" | ||
339 | + second_link_list_block.title = "Software Público" | ||
340 | + second_link_list_block.fixed = true | ||
341 | + second_link_list_block.save! | ||
342 | + | ||
343 | + second_link_list_block.links << {:icon => "no-icon", :name => "Entenda o que é", :address => "/#{identifier}/entenda-o-que-e", :target => "_self"} | ||
344 | + second_link_list_block.links << {:icon => "no-icon", :name => "Inicie um projeto", :address => "/#{identifier}/inicie-um-projeto", :target => "_self"} | ||
345 | + second_link_list_block.links << {:icon => "no-icon", :name => "Publique seu software", :address => "/#{identifier}/publique-seu-software", :target => "_self"} | ||
346 | + second_link_list_block.save! | ||
347 | + box2.blocks << second_link_list_block | ||
348 | + box2.save! | ||
349 | + puts "Second LinkListBlock successfully added to software!" | ||
350 | + | ||
351 | + third_link_list_block = LinkListBlock.new | ||
352 | + third_link_list_block.position = 1 | ||
353 | + third_link_list_block.display = "always" | ||
354 | + third_link_list_block.title = "" | ||
355 | + third_link_list_block.fixed = true | ||
356 | + third_link_list_block.save! | ||
357 | + | ||
358 | + third_link_list_block.links << {:icon => "no-icon", :name => "Catálogo de Software Público", :address => "#", :target => "_self"} | ||
359 | + third_link_list_block.links << {:icon => "no-icon", :name => "Comunidades", :address => "/search/communities", :target => "_self"} | ||
360 | + | ||
361 | + third_link_list_block.save! | ||
362 | + box2.blocks << third_link_list_block | ||
363 | + box2.save! | ||
364 | + puts "Third LinkListBlock successfully added to software!" | ||
365 | + else | ||
366 | + puts "IMPOSSIBLE TO CREATE FIXED BLOCKS, THERE IS NO COMMUNITY CALLED SPB" | ||
367 | + end | ||
368 | + end | ||
309 | end | 369 | end |