]> source.dussan.org Git - sonarqube.git/commitdiff
do not display the delete button on profiles inherited by other profiles
authorsimonbrandhof <simon.brandhof@gmail.com>
Wed, 22 Dec 2010 23:25:28 +0000 (23:25 +0000)
committersimonbrandhof <simon.brandhof@gmail.com>
Wed, 22 Dec 2010 23:25:28 +0000 (23:25 +0000)
sonar-server/src/main/java/org/sonar/server/startup/DeleteDeprecatedMeasures.java
sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb
sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/profiles/inheritance.html.erb

index 42f2333166313e34c007b5c03fd84f0e1100f42e..eed02cc31b405fc8e8b71df571a488e7aaba28bd 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.startup;
 
-import org.slf4j.LoggerFactory;
 import org.sonar.api.database.DatabaseSession;
 import org.sonar.api.database.model.MeasureModel;
 import org.sonar.api.platform.ServerUpgradeStatus;
@@ -52,7 +51,7 @@ public final class DeleteDeprecatedMeasures {
   }
 
   boolean mustDoPurge() {
-    return status.isUpgraded() && status.getInitialDbVersion()<=162;
+    return status.isUpgraded() && status.getInitialDbVersion() <= 162;
   }
 
   void doPurge() {
index fcd05e004fda7709885290bfbcce304eb49a5d59..9ab8bb3d36646a3c6f15958e1cf498d6211ddbe4 100644 (file)
@@ -93,7 +93,7 @@ class ProfilesController < ApplicationController
   #
   def delete
     @profile = Profile.find(params[:id])
-    if @profile && !@profile.provided? && !@profile.default_profile?
+    if @profile && @profile.deletable?
       java_facade.deleteProfile(@profile.id)
       flash[:notice]="Profile '#{@profile.name}' is deleted."
     end
index 956e93a7f3d95a305e5afb03742e9a91272b6fb8..1c32e0827041389418dfcb7a76dffd3bc7d8b7d6 100644 (file)
@@ -100,6 +100,10 @@ class Profile < ActiveRecord::Base
     @active_hash_by_rule_id
   end
 
+  def deletable?
+    !provided? && !default_profile? && children.empty?
+  end
+
   def inherited?
     parent_name.present?
   end
index d402cf272b588969e7e4e7e9a0a6d9980edf6ca6..0c75209fe57de14cb45dd6729ba80f478c13bcfa 100644 (file)
         </td>
 
         <td>
-            <% if (!(profile.provided?) && !(profile.default_profile?)) %>
+            <% if profile.deletable? %>
             <%= button_to "Delete", { :action => 'delete', :id => profile.id }, :class => 'action',
                         :id => "delete_#{u profile.key}",
                         :confirm => "Are you sure that you want to delete the profile '#{profile.name}' ?",
index 7d3e1c04da99765ca40a4180b88ec2781fc4139c..50c95d98ec060b8d0c2cf663a12c25bebcf646bb 100644 (file)
@@ -29,7 +29,7 @@
        <td valign="top" width="300">
          <div class="admin">
          <% if @profile.provided? %>
-           <p>This profile can not be changed.</p>
+           <p>This profile can not be edited.</p>
 
          <% else %>
            <h3>Set parent:</h3>