Commit 505610845aa69a1e24b3eafb1dad1302ad91265d

Authored by Antonio Terceiro
1 parent 4297efaa

ActionItem862: still testing upgrade

Showing 2 changed files with 32 additions and 17 deletions   Show diff stats
script/apply-template
@@ -6,6 +6,16 @@ set_locale_all 'pt_BR' @@ -6,6 +6,16 @@ set_locale_all 'pt_BR'
6 6
7 env = Environment.default 7 env = Environment.default
8 8
  9 +def move_articles_to_blog(profile)
  10 + profile.articles.each { |article|
  11 + puts 'including ' + article.path + ' in the blog'
  12 + if !article.blog? && !article.is_a?(RssFeed)
  13 + article.parent_id = profile.blog.id
  14 + article.save!
  15 + end
  16 + }
  17 +end
  18 +
9 case $ARGV[0] 19 case $ARGV[0]
10 when 'inactive-enterprise' 20 when 'inactive-enterprise'
11 offset = 0 21 offset = 0
@@ -25,28 +35,31 @@ when 'inactive-enterprise' @@ -25,28 +35,31 @@ when 'inactive-enterprise'
25 end 35 end
26 when 'active-enterprise' 36 when 'active-enterprise'
27 active_enterprises = Enterprise.find(:all, :conditions => {:enabled => true}) - [env.enterprise_template, env.enterprise_template] 37 active_enterprises = Enterprise.find(:all, :conditions => {:enabled => true}) - [env.enterprise_template, env.enterprise_template]
28 - active_enterprises.each { |enterprise| enterprise.apply_template(env.enterprise_template) } 38 + active_enterprises.each do |enterprise|
  39 + old_home = enterprise.home_page
  40 + enterprise.apply_template(env.enterprise_template)
  41 + enterprise.home_page.update_attributes!(:body => old_home.body)
  42 + enterprise.save!
  43 + end
29 when 'community' 44 when 'community'
30 - communities = Community.find(:all) - [Community['espaco'], Community['anarquismo']]  
31 - communities.each { |community|  
32 - puts 'c: ' + community.identifier  
33 - community.apply_template(env.community_template)  
34 - community.reload  
35 - puts 'template applied'  
36 - community.articles.each { |article|  
37 - puts 'including ' + article.path + ' in the blog'  
38 - if !article.blog? && !article.is_a?(RssFeed)  
39 - article.parent_id = community.blog.id  
40 - article.save!  
41 - end  
42 - }  
43 - }  
44 -when 'person' 45 + excluded = ['espaco', 'anarquismo']
  46 + template = env.community_template
45 offset = 0 47 offset = 0
  48 + while community = Community.find(:first, :order => :id, :offset => offset)
  49 + if community != template && !excluded.include?(community.identifier)
  50 + community.apply_template(template)
  51 + move_articles_to_blog(community)
  52 + puts "#{offset} - #{community.identifier}"
  53 + end
  54 + offset = offset + 1
  55 + end
  56 +when 'person'
46 template = env.person_template 57 template = env.person_template
  58 + offset = 0
47 while person = Person.find(:first, :order => :id, :offset => offset) 59 while person = Person.find(:first, :order => :id, :offset => offset)
48 if person != template 60 if person != template
49 person.apply_template(template) 61 person.apply_template(template)
  62 + move_articles_to_blog(person)
50 puts "#{offset} - #{person.identifier}" 63 puts "#{offset} - #{person.identifier}"
51 end 64 end
52 offset = offset + 1 65 offset = offset + 1
script/test-0.13
1 #!/bin/sh 1 #!/bin/sh
2 2
3 rm -f db/*.db 3 rm -f db/*.db
4 -find public/images/ -name \*big\* -delete 4 +find public/images/[0-9]* -name \*big\* -delete
5 rake db:schema:load 5 rake db:schema:load
6 rake db:populate 6 rake db:populate
7 ruby script/anhetegua 7 ruby script/anhetegua
8 8
9 ./script/runner ' 9 ./script/runner '
  10 + Enterprise["colivre"].home_page.update_attributes!(:body => "Content created by Colivre must not be lost")
  11 +
10 Enterprise.create!(:name => "Desabilitada", :identifier => "desabilitada", :enabled => false, :environment => Environment.default) 12 Enterprise.create!(:name => "Desabilitada", :identifier => "desabilitada", :enabled => false, :environment => Environment.default)
11 ' 13 '
12 14