diff --git a/app/models/environment.rb b/app/models/environment.rb index 13acfde..5a71630 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -238,7 +238,7 @@ class Environment < ActiveRecord::Base end def custom_person_fields=(values) - if values['schooling'] && values['schooling']['active'] == 'true' + if values['schooling'] && values['schooling']['active'] == 'true' schooling_status = values['schooling'] end self.settings[:custom_person_fields] = values.delete_if { |key, value| ! Person.fields.include?(key)} diff --git a/script/apply-enterprise-inactive-template b/script/apply-enterprise-inactive-template deleted file mode 100644 index 2aa8bd5..0000000 --- a/script/apply-enterprise-inactive-template +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/environment' -include GetText -ActionController::Base.init_gettext 'noosfero' -set_locale_all 'pt_BR' - -e = Environment.default -inactive_enterprises = Enterprise.find(:all, :conditions => ['enabled = ?', false]) - [e.inactive_enterprise_template, e.enterprise_template] -apply_in = inactive_enterprises[$ARGV[0].to_i..$ARGV[1].to_i] -apply_in.each_with_index { |obj,i| obj.apply_template(e.inactive_enterprise_template); puts i.to_s + ' - ' + obj.identifier} diff --git a/script/apply-template b/script/apply-template new file mode 100755 index 0000000..7c60d71 --- /dev/null +++ b/script/apply-template @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +require File.dirname(__FILE__) + '/../config/environment' +include GetText +ActionController::Base.init_gettext 'noosfero' +set_locale_all 'pt_BR' + +env = Environment.default + +case $ARGV[0] +when 'inactive-enterprise' + inactive_enterprises = Enterprise.find(:all, :conditions => {:enabled => false}) - [env.inactive_enterprise_template, env.enterprise_template] + apply_in = inactive_enterprises[$ARGV[1].to_i..$ARGV[2].to_i] + apply_in.each_with_index { |obj,i| obj.apply_template(env.inactive_enterprise_template); puts i.to_s + ' - ' + obj.identifier} unless apply_in.nil? +when 'active-enterprise' + active_enterprises = Enterprise.find(:all, :conditions => {:enabled => true}) - [env.enterprise_template, env.enterprise_template] + active_enterprises.each { |enterprise| enterprise.apply_template(env.enterprise_template) } +when 'community' + communities = Community.find(:all) - [Community['espaco'], Community['anarquismo']] + communities.each { |community| + community.apply_template(env.community_template) + blog = community.blog + community.articles.select{|i| !i.blog? or i != blog.feed}.each{ |article| + article.parent = blog + article.save! + } + } +end + + diff --git a/script/release-v0.13.0-ecosol b/script/release-v0.13.0-ecosol new file mode 100755 index 0000000..b36da53 --- /dev/null +++ b/script/release-v0.13.0-ecosol @@ -0,0 +1,131 @@ +#!/bin/sh + +export RAILS_ENV=production + +echo 'Creating Big images...' +script/generate-profile-big-images + +echo 'Configurating templates...' +script/runner 'env = Environment.default; + e = Enterprise.create!(:name => "Inactive enterprise template", :identifier => env.name.to_slug + "_inactive_enterprise_template", :environment => env, :public_profile => false); + env.inactive_enterprise_template = e; + env.add_templates = [env.community_template, env.person_template, env.enterprise_template, env.inactive_enterprise_template]; + env.save!' + +echo 'Configurating template for active enterprises..' +script/runner 'env = Environment.default + template = env.enterprise_template + template.custom_footer = "
{address} {- zip_code}
{city} {- state} {- country}
{Tel: contact_phone} {e-Mail: contact_email}
" + template.custom_header = "

{name}


" + template.articles.destroy_all + homepage = TinyMceArticle.create!(:name => "Início", :body => "Esta é a página inicial do seu empreendimento", :profile => template, :accept_comments => false) + template.home_page = homepage + TinyMceArticle.create!(:name => "Quem somos", :body => "Aqui você pode falar sobre o seu empreendimento.", :profile => template, :accept_comments => false) + TinyMceArticle.create!(:name => "Pontos de venda", :body => "Aqui você pode falar sobre os seus pontos de venda.", :profile => template, :accept_comments => false) + template.layout_template = "leftbar" + main = template.boxes[0] + left = template.boxes[1] + main.blocks.destroy_all + left.blocks.destroy_all + left.blocks << ProfileImageBlock.new + left.blocks << LinkListBlock.new(:links => [ + {:name => "Início", :address => "/{profile}"}, + {:name => "Quem somos", :address => "/{profile}/quem-somos"}, + {:name => "Nossos produtos", :address => "/catalog/{profile}"}, + {:name => "Pontos de venda", :address => "/{profile}/pontos-de-venda"}, + {:name => "Fale conosco", :address => "/contact/{profile}/new"} + ]) + left.blocks << LocalizationBlock.new + main.blocks << MainBlock.new + template.save!' + +echo 'Configurating template for inactive enterprises..' +script/runner 'env = Environment.default + template = env.inactive_enterprise_template + template.articles.destroy_all + homepage = EnterpriseHomepage.create!(:name => "Início", :profile => template, :accept_comments => false) + template.home_page = homepage + template.layout_template = "leftbar" + main = template.boxes[0] + left = template.boxes[1] + main.blocks.destroy_all + left.blocks.destroy_all + left.blocks << [ProfileImageBlock.new, DisabledEnterpriseMessageBlock.new] + main.blocks << MainBlock.new + template.save!' + +echo 'Applying template for inactive enterprises (require bc calculator)...' +start=0; +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 + end=`echo "$i * 1000" | bc`; + script/apply-template 'inactive-enterprise' $start $end; + start=$end; +done + +echo 'Applying template for active enterprises...' +script/apply-template 'active-enterprise' + +echo 'Enabling replace enterprise template when enable...' +script/runner 'env = Environment.default; + env.replace_enterprise_template_when_enable = true; + env.save!;' + +echo 'ATENCAO: Copie o tema (via scp) empreendimento-solidario para public/designs/themes/' +echo ' Nao esqueca de copiar o footer.rhtml do tema default' +echo ' (e pressione ENTER para continuar)' +read + +echo 'Applying empreendimento-solidario theme...' +script/runner 'c = Enterprise.connection; + c.execute("UPDATE profiles SET theme = \"empreendimento-solidario\" WHERE type = \"Enterprise\"")' + +echo 'Configurating template for person...' +script/runner 'env = Environment.default + template = env.person_template + main = template.boxes[0] + left = template.boxes[1] + right = template.boxes[2] + main.blocks.destroy_all unless main.nil? + left.blocks.destroy_all unless left.nil? + right.blocks.destroy_all unless right.nil? + left.blocks << [ProfileInfoBlock.new, RecentDocumentsBlock.new, BlogArchivesBlock.new] + right.blocks << [FriendsBlock.new, EnterprisesBlock.new, CommunitiesBlock.new] + main.blocks << MainBlock.new + template.articles.destroy_all + template.articles << Blog.new(:name => "Meu blog", :profile => template) + template.home_page = template.blog + template.save!' + +echo 'Configurating template for community...' +script/runner 'env = Environment.default + template = env.community_template + main = template.boxes[0] + left = template.boxes[1] + right = template.boxes[2] + main.blocks.destroy_all unless main.nil? + left.blocks.destroy_all unless left.nil? + right.blocks.destroy_all unless right.nil? + left.blocks << [ProfileInfoBlock.new, RecentDocumentsBlock.new, BlogArchivesBlock.new] + right.blocks << MembersBlock.new + main.blocks << MainBlock.new + template.articles.destroy_all + template.articles << Blog.new(:name => "Meu blog", :profile => template) + template.home_page = template.blog + template.save!' + +echo 'Applying template for communities...' +script/apply-template 'community' + +echo 'Schedule task-nitifier script...' +echo 'ATENCAO: Agende o script task-notifier no crontab para executar mensalmente' +echo ' Não esqueça de setar no environment.rb o ambiente para production' +echo ' (pressione ENTER para continuar)' +read + +echo 'Disabling CMS...' +script/runner 'env = Environment.default + env.enable("disable_cms") + env.save!' + +echo 'Publishing theme empreendimento-solidario...' +echo 'NOT IMPLEMENTED YET' -- libgit2 0.21.2