Commit 505610845aa69a1e24b3eafb1dad1302ad91265d
1 parent
4297efaa
Exists in
master
and in
29 other branches
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 | |
7 | 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 | 19 | case $ARGV[0] |
10 | 20 | when 'inactive-enterprise' |
11 | 21 | offset = 0 |
... | ... | @@ -25,28 +35,31 @@ when 'inactive-enterprise' |
25 | 35 | end |
26 | 36 | when 'active-enterprise' |
27 | 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 | 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 | 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 | 57 | template = env.person_template |
58 | + offset = 0 | |
47 | 59 | while person = Person.find(:first, :order => :id, :offset => offset) |
48 | 60 | if person != template |
49 | 61 | person.apply_template(template) |
62 | + move_articles_to_blog(person) | |
50 | 63 | puts "#{offset} - #{person.identifier}" |
51 | 64 | end |
52 | 65 | offset = offset + 1 | ... | ... |
script/test-0.13
1 | 1 | #!/bin/sh |
2 | 2 | |
3 | 3 | rm -f db/*.db |
4 | -find public/images/ -name \*big\* -delete | |
4 | +find public/images/[0-9]* -name \*big\* -delete | |
5 | 5 | rake db:schema:load |
6 | 6 | rake db:populate |
7 | 7 | ruby script/anhetegua |
8 | 8 | |
9 | 9 | ./script/runner ' |
10 | + Enterprise["colivre"].home_page.update_attributes!(:body => "Content created by Colivre must not be lost") | |
11 | + | |
10 | 12 | Enterprise.create!(:name => "Desabilitada", :identifier => "desabilitada", :enabled => false, :environment => Environment.default) |
11 | 13 | ' |
12 | 14 | ... | ... |