From c951cc6b6f71e8253ac9992eb58d7de3a635310b Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Wed, 1 Aug 2012 00:58:59 +0800 Subject: [PATCH] Fix for data_migration --- lib/tasks/data_migration.rake | 5 ++++- vendor/built_in_modules/announcement/app/models/bulletin.rb | 2 +- vendor/built_in_modules/news/app/models/news_bulletin.rb | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/tasks/data_migration.rake b/lib/tasks/data_migration.rake index 5d5f5446..1a992126 100644 --- a/lib/tasks/data_migration.rake +++ b/lib/tasks/data_migration.rake @@ -45,6 +45,7 @@ namespace :data_migration do end task :make_bulletins_and_news_has_language_flag => :environment do + a = [] [Bulletin,NewsBulletin].each do |bulletin| puts "="*10 + bulletin.to_s + "="*10 bulletin.all.each do |bt| @@ -52,10 +53,12 @@ namespace :data_migration do "OK" else 'Failed' + a << bt.id end - puts(bt.title+"----------#{result}") + puts((bt.title.to_s rescue '') + "----------#{result}") end end + p a puts("#{'='*10}Finished#{'='*10}") end diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb index 63cdde94..e70acf57 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -232,7 +232,7 @@ class Bulletin def update_avliable_language VALID_LOCALES.each do |locale| - unless title[locale].blank? || subtitle[locale].blank? || text[locale].blank? + if (title_translations[locale].blank? rescue true) self["available_for_#{locale}".to_sym] = false else self["available_for_#{locale}".to_sym] = true diff --git a/vendor/built_in_modules/news/app/models/news_bulletin.rb b/vendor/built_in_modules/news/app/models/news_bulletin.rb index 6c87e018..3fdabd56 100644 --- a/vendor/built_in_modules/news/app/models/news_bulletin.rb +++ b/vendor/built_in_modules/news/app/models/news_bulletin.rb @@ -205,7 +205,7 @@ class NewsBulletin protected def update_avliable_language VALID_LOCALES.each do |locale| - unless title[locale].blank? || subtitle[locale].blank? || text[locale].blank? + if (title_translations[locale].blank? rescue true) self["available_for_#{locale}".to_sym] = false else self["available_for_#{locale}".to_sym] = true