aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabrice Bellingard <bellingard@gmail.com>2011-12-14 15:44:00 +0100
committerFabrice Bellingard <bellingard@gmail.com>2011-12-14 15:44:35 +0100
commit9179fbeead620330cdaa5a8ab6291c893d95c571 (patch)
tree419dd4fe03d0bc424f6ee5e52601ad976a07b17d
parent62a1cb35eae3d226c64220139dd45fad20fe9082 (diff)
downloadsonarqube-9179fbeead620330cdaa5a8ab6291c893d95c571.tar.gz
sonarqube-9179fbeead620330cdaa5a8ab6291c893d95c571.zip
SONAR-1929 Fix problem migration (I18n API not initialized)
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/dashboard.rb18
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/236_add_key_to_dashboards.rb7
2 files changed, 16 insertions, 9 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/dashboard.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/dashboard.rb
index bb5c54c1a84..c48acf060f0 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/dashboard.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/dashboard.rb
@@ -32,13 +32,21 @@ class Dashboard < ActiveRecord::Base
validates_uniqueness_of :name, :scope => :user_id
before_create { |dashboard| dashboard.kee=dashboard.name.strip.downcase.sub(/\s+/, '_') }
-
- def name
- Api::Utils.message("dashboard.#{kee}.name", :default => read_attribute(:name))
+
+ def name(l10n=true)
+ if l10n
+ Api::Utils.message("dashboard.#{kee}.name", :default => read_attribute(:name))
+ else
+ read_attribute(:name)
+ end
end
- def description
- Api::Utils.message("dashboard.#{kee}.description", :default => read_attribute(:description))
+ def description(l10n=true)
+ if l10n
+ Api::Utils.message("dashboard.#{kee}.description", :default => read_attribute(:description))
+ else
+ read_attribute(:description)
+ end
end
def shared?
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/236_add_key_to_dashboards.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/236_add_key_to_dashboards.rb
index d1031a6eeeb..04c287e98b0 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/236_add_key_to_dashboards.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/236_add_key_to_dashboards.rb
@@ -28,14 +28,13 @@ class AddKeyToDashboards < ActiveRecord::Migration
Dashboard.reset_column_information
Dashboard.find(:all).each do |d|
- d.kee = d.name.strip.downcase.sub(/\s+/, '_')
- d.save
+ key = d.name(false).strip.downcase.sub(/\s+/, '_')
+ Dashboard.update_all "kee = '#{key}'", ["id = ?", d.id]
end
main_dashboard = Dashboard.find(:first, :conditions => {:name => 'Dashboard'})
if main_dashboard
- main_dashboard.kee = 'sonar-main'
- main_dashboard.save
+ Dashboard.update_all "kee = 'sonar-main'", ["id = ?", main_dashboard.id]
end
change_column 'dashboards', 'kee', :string, :limit => 200, :null => false