Commit 1cc1999dae394fbc847b5a4b34f1c0c9978bc86c
1 parent
7abf5f14
Exists in
master
and in
29 other branches
ActionItem862: automating tasks to release the ecosol v0.13.0
Showing
4 changed files
with
161 additions
and
11 deletions
Show diff stats
app/models/environment.rb
| ... | ... | @@ -238,7 +238,7 @@ class Environment < ActiveRecord::Base |
| 238 | 238 | end |
| 239 | 239 | |
| 240 | 240 | def custom_person_fields=(values) |
| 241 | - if values['schooling'] && values['schooling']['active'] == 'true' | |
| 241 | + if values['schooling'] && values['schooling']['active'] == 'true' | |
| 242 | 242 | schooling_status = values['schooling'] |
| 243 | 243 | end |
| 244 | 244 | self.settings[:custom_person_fields] = values.delete_if { |key, value| ! Person.fields.include?(key)} | ... | ... |
script/apply-enterprise-inactive-template
| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | -#!/usr/bin/env ruby | |
| 2 | -require File.dirname(__FILE__) + '/../config/environment' | |
| 3 | -include GetText | |
| 4 | -ActionController::Base.init_gettext 'noosfero' | |
| 5 | -set_locale_all 'pt_BR' | |
| 6 | - | |
| 7 | -e = Environment.default | |
| 8 | -inactive_enterprises = Enterprise.find(:all, :conditions => ['enabled = ?', false]) - [e.inactive_enterprise_template, e.enterprise_template] | |
| 9 | -apply_in = inactive_enterprises[$ARGV[0].to_i..$ARGV[1].to_i] | |
| 10 | -apply_in.each_with_index { |obj,i| obj.apply_template(e.inactive_enterprise_template); puts i.to_s + ' - ' + obj.identifier} |
| ... | ... | @@ -0,0 +1,29 @@ |
| 1 | +#!/usr/bin/env ruby | |
| 2 | +require File.dirname(__FILE__) + '/../config/environment' | |
| 3 | +include GetText | |
| 4 | +ActionController::Base.init_gettext 'noosfero' | |
| 5 | +set_locale_all 'pt_BR' | |
| 6 | + | |
| 7 | +env = Environment.default | |
| 8 | + | |
| 9 | +case $ARGV[0] | |
| 10 | +when 'inactive-enterprise' | |
| 11 | + inactive_enterprises = Enterprise.find(:all, :conditions => {:enabled => false}) - [env.inactive_enterprise_template, env.enterprise_template] | |
| 12 | + apply_in = inactive_enterprises[$ARGV[1].to_i..$ARGV[2].to_i] | |
| 13 | + apply_in.each_with_index { |obj,i| obj.apply_template(env.inactive_enterprise_template); puts i.to_s + ' - ' + obj.identifier} unless apply_in.nil? | |
| 14 | +when 'active-enterprise' | |
| 15 | + active_enterprises = Enterprise.find(:all, :conditions => {:enabled => true}) - [env.enterprise_template, env.enterprise_template] | |
| 16 | + active_enterprises.each { |enterprise| enterprise.apply_template(env.enterprise_template) } | |
| 17 | +when 'community' | |
| 18 | + communities = Community.find(:all) - [Community['espaco'], Community['anarquismo']] | |
| 19 | + communities.each { |community| | |
| 20 | + community.apply_template(env.community_template) | |
| 21 | + blog = community.blog | |
| 22 | + community.articles.select{|i| !i.blog? or i != blog.feed}.each{ |article| | |
| 23 | + article.parent = blog | |
| 24 | + article.save! | |
| 25 | + } | |
| 26 | + } | |
| 27 | +end | |
| 28 | + | |
| 29 | + | ... | ... |
| ... | ... | @@ -0,0 +1,131 @@ |
| 1 | +#!/bin/sh | |
| 2 | + | |
| 3 | +export RAILS_ENV=production | |
| 4 | + | |
| 5 | +echo 'Creating Big images...' | |
| 6 | +script/generate-profile-big-images | |
| 7 | + | |
| 8 | +echo 'Configurating templates...' | |
| 9 | +script/runner 'env = Environment.default; | |
| 10 | + e = Enterprise.create!(:name => "Inactive enterprise template", :identifier => env.name.to_slug + "_inactive_enterprise_template", :environment => env, :public_profile => false); | |
| 11 | + env.inactive_enterprise_template = e; | |
| 12 | + env.add_templates = [env.community_template, env.person_template, env.enterprise_template, env.inactive_enterprise_template]; | |
| 13 | + env.save!' | |
| 14 | + | |
| 15 | +echo 'Configurating template for active enterprises..' | |
| 16 | +script/runner 'env = Environment.default | |
| 17 | + template = env.enterprise_template | |
| 18 | + template.custom_footer = "<div align=center>{address} {- zip_code}<br/>{city} {- state} {- country}<br/>{Tel: contact_phone} {e-Mail: contact_email}<br/></div>" | |
| 19 | + template.custom_header = "<div align=center><h1>{name}</h1><br/></div>" | |
| 20 | + template.articles.destroy_all | |
| 21 | + homepage = TinyMceArticle.create!(:name => "Início", :body => "Esta é a página inicial do seu empreendimento", :profile => template, :accept_comments => false) | |
| 22 | + template.home_page = homepage | |
| 23 | + TinyMceArticle.create!(:name => "Quem somos", :body => "Aqui você pode falar sobre o seu empreendimento.", :profile => template, :accept_comments => false) | |
| 24 | + TinyMceArticle.create!(:name => "Pontos de venda", :body => "Aqui você pode falar sobre os seus pontos de venda.", :profile => template, :accept_comments => false) | |
| 25 | + template.layout_template = "leftbar" | |
| 26 | + main = template.boxes[0] | |
| 27 | + left = template.boxes[1] | |
| 28 | + main.blocks.destroy_all | |
| 29 | + left.blocks.destroy_all | |
| 30 | + left.blocks << ProfileImageBlock.new | |
| 31 | + left.blocks << LinkListBlock.new(:links => [ | |
| 32 | + {:name => "Início", :address => "/{profile}"}, | |
| 33 | + {:name => "Quem somos", :address => "/{profile}/quem-somos"}, | |
| 34 | + {:name => "Nossos produtos", :address => "/catalog/{profile}"}, | |
| 35 | + {:name => "Pontos de venda", :address => "/{profile}/pontos-de-venda"}, | |
| 36 | + {:name => "Fale conosco", :address => "/contact/{profile}/new"} | |
| 37 | + ]) | |
| 38 | + left.blocks << LocalizationBlock.new | |
| 39 | + main.blocks << MainBlock.new | |
| 40 | + template.save!' | |
| 41 | + | |
| 42 | +echo 'Configurating template for inactive enterprises..' | |
| 43 | +script/runner 'env = Environment.default | |
| 44 | + template = env.inactive_enterprise_template | |
| 45 | + template.articles.destroy_all | |
| 46 | + homepage = EnterpriseHomepage.create!(:name => "Início", :profile => template, :accept_comments => false) | |
| 47 | + template.home_page = homepage | |
| 48 | + template.layout_template = "leftbar" | |
| 49 | + main = template.boxes[0] | |
| 50 | + left = template.boxes[1] | |
| 51 | + main.blocks.destroy_all | |
| 52 | + left.blocks.destroy_all | |
| 53 | + left.blocks << [ProfileImageBlock.new, DisabledEnterpriseMessageBlock.new] | |
| 54 | + main.blocks << MainBlock.new | |
| 55 | + template.save!' | |
| 56 | + | |
| 57 | +echo 'Applying template for inactive enterprises (require bc calculator)...' | |
| 58 | +start=0; | |
| 59 | +for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21; do | |
| 60 | + end=`echo "$i * 1000" | bc`; | |
| 61 | + script/apply-template 'inactive-enterprise' $start $end; | |
| 62 | + start=$end; | |
| 63 | +done | |
| 64 | + | |
| 65 | +echo 'Applying template for active enterprises...' | |
| 66 | +script/apply-template 'active-enterprise' | |
| 67 | + | |
| 68 | +echo 'Enabling replace enterprise template when enable...' | |
| 69 | +script/runner 'env = Environment.default; | |
| 70 | + env.replace_enterprise_template_when_enable = true; | |
| 71 | + env.save!;' | |
| 72 | + | |
| 73 | +echo 'ATENCAO: Copie o tema (via scp) empreendimento-solidario para public/designs/themes/' | |
| 74 | +echo ' Nao esqueca de copiar o footer.rhtml do tema default' | |
| 75 | +echo ' (e pressione ENTER para continuar)' | |
| 76 | +read | |
| 77 | + | |
| 78 | +echo 'Applying empreendimento-solidario theme...' | |
| 79 | +script/runner 'c = Enterprise.connection; | |
| 80 | + c.execute("UPDATE profiles SET theme = \"empreendimento-solidario\" WHERE type = \"Enterprise\"")' | |
| 81 | + | |
| 82 | +echo 'Configurating template for person...' | |
| 83 | +script/runner 'env = Environment.default | |
| 84 | + template = env.person_template | |
| 85 | + main = template.boxes[0] | |
| 86 | + left = template.boxes[1] | |
| 87 | + right = template.boxes[2] | |
| 88 | + main.blocks.destroy_all unless main.nil? | |
| 89 | + left.blocks.destroy_all unless left.nil? | |
| 90 | + right.blocks.destroy_all unless right.nil? | |
| 91 | + left.blocks << [ProfileInfoBlock.new, RecentDocumentsBlock.new, BlogArchivesBlock.new] | |
| 92 | + right.blocks << [FriendsBlock.new, EnterprisesBlock.new, CommunitiesBlock.new] | |
| 93 | + main.blocks << MainBlock.new | |
| 94 | + template.articles.destroy_all | |
| 95 | + template.articles << Blog.new(:name => "Meu blog", :profile => template) | |
| 96 | + template.home_page = template.blog | |
| 97 | + template.save!' | |
| 98 | + | |
| 99 | +echo 'Configurating template for community...' | |
| 100 | +script/runner 'env = Environment.default | |
| 101 | + template = env.community_template | |
| 102 | + main = template.boxes[0] | |
| 103 | + left = template.boxes[1] | |
| 104 | + right = template.boxes[2] | |
| 105 | + main.blocks.destroy_all unless main.nil? | |
| 106 | + left.blocks.destroy_all unless left.nil? | |
| 107 | + right.blocks.destroy_all unless right.nil? | |
| 108 | + left.blocks << [ProfileInfoBlock.new, RecentDocumentsBlock.new, BlogArchivesBlock.new] | |
| 109 | + right.blocks << MembersBlock.new | |
| 110 | + main.blocks << MainBlock.new | |
| 111 | + template.articles.destroy_all | |
| 112 | + template.articles << Blog.new(:name => "Meu blog", :profile => template) | |
| 113 | + template.home_page = template.blog | |
| 114 | + template.save!' | |
| 115 | + | |
| 116 | +echo 'Applying template for communities...' | |
| 117 | +script/apply-template 'community' | |
| 118 | + | |
| 119 | +echo 'Schedule task-nitifier script...' | |
| 120 | +echo 'ATENCAO: Agende o script task-notifier no crontab para executar mensalmente' | |
| 121 | +echo ' Não esqueça de setar no environment.rb o ambiente para production' | |
| 122 | +echo ' (pressione ENTER para continuar)' | |
| 123 | +read | |
| 124 | + | |
| 125 | +echo 'Disabling CMS...' | |
| 126 | +script/runner 'env = Environment.default | |
| 127 | + env.enable("disable_cms") | |
| 128 | + env.save!' | |
| 129 | + | |
| 130 | +echo 'Publishing theme empreendimento-solidario...' | |
| 131 | +echo 'NOT IMPLEMENTED YET' | ... | ... |