aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorDavid Gageot <david@gageot.net>2012-05-24 08:22:55 +0200
committerDavid Gageot <david@gageot.net>2012-05-24 09:34:58 +0200
commitd9538939baa6cd86340505da1f4283ac12a94cb8 (patch)
tree1ded7ae835553cfcfbe21d5fc44b2a90722cef06 /sonar-server
parent764537e903cef07f68b0a0d97e6b925e19363170 (diff)
downloadsonarqube-d9538939baa6cd86340505da1f4283ac12a94cb8.tar.gz
sonarqube-d9538939baa6cd86340505da1f4283ac12a94cb8.zip
Create Projects and Treemap default dashboards using extension point
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/305_ignore_loaded_dashboards.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/305_ignore_loaded_dashboards.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/305_ignore_loaded_dashboards.rb
new file mode 100644
index 00000000000..75dd8c7a7be
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/305_ignore_loaded_dashboards.rb
@@ -0,0 +1,43 @@
+#
+# Sonar, open source software quality management tool.
+# Copyright (C) 2008-2012 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# Sonar is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 3 of the License, or (at your option) any later version.
+#
+# Sonar is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with Sonar; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+#
+
+#
+# Sonar 3.1
+#
+class IgnoreLoadedDashboards < ActiveRecord::Migration
+ class Dashboard < ActiveRecord::Base
+ end
+
+ class LoadedTemplate < ActiveRecord::Base
+ end
+
+ def self.up
+ mark_dashboard_as_loaded('Projects')
+ mark_dashboard_as_loaded('Treemap')
+ end
+
+ def self.mark_dashboard_as_loaded(name)
+ if Dashboard.find(:first, :conditions => {:name => name, :user_id => nil})
+ unless LoadedTemplate.find(:first, :conditions => {:kee => name, :template_type => 'DASHBOARD'})
+ LoadedTemplate.create(:kee => name, :template_type => 'DASHBOARD').save
+ end
+ end
+ end
+end