From dcfd76040b93526d452e1b9840caf2b167fd877a Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Thu, 14 Mar 2013 10:12:44 +0100 Subject: [PATCH] Replace enabled by status --- .../controllers/rules_configuration_controller.rb | 14 +++++++++----- .../app/views/rules_configuration/index.html.erb | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb index 4b49fa192a2..7838203050c 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb @@ -101,7 +101,7 @@ class RulesConfigurationController < ApplicationController def activate_rule profile = Profile.find(params[:id].to_i) if profile - rule=Rule.find(:first, :conditions => {:id => params[:rule_id].to_i, :enabled => true}) + rule=Rule.first(:conditions => ["id = ? and status <> ?", params[:rule_id].to_i, Rule::STATUS_REMOVED]) priority=params[:level] active_rule=profile.active_by_rule_id(rule.id) @@ -161,6 +161,7 @@ class RulesConfigurationController < ApplicationController # # def create + profile = Profile.find(params[:id].to_i) template=Rule.find(params[:rule_id]) rule=Rule.create(params[:rule].merge( { @@ -170,7 +171,10 @@ class RulesConfigurationController < ApplicationController :cardinality => 'SINGLE', :plugin_rule_key => "#{template.plugin_rule_key}_#{Time.now.to_i}", :plugin_config_key => template.plugin_config_key, - :enabled => true})) + :status => Rule::STATUS_READY, + :language => profile.language + } + )) template.parameters.each do |template_parameter| rule.rules_parameters.build(:name => template_parameter.name, :param_type => template_parameter.param_type, :description => template_parameter.description, @@ -178,11 +182,11 @@ class RulesConfigurationController < ApplicationController end if rule.save - redirect_to :action => 'index', :id => params[:id], :searchtext => rule.name, :rule_activation => 'INACTIVE', "plugins[]" => rule.plugin_name + redirect_to :action => 'index', :id => profile.id, :searchtext => rule.name, :rule_activation => 'INACTIVE', "plugins[]" => rule.plugin_name else flash[:error]=message('rules_configuration.rule_not_valid_message_x', :params => rule.errors.full_messages.join('
')) - redirect_to :action => 'new', :id => params[:id], :rule_id => params[:rule_id] + redirect_to :action => 'new', :id => profile.id, :rule_id => params[:rule_id] end end @@ -242,7 +246,7 @@ class RulesConfigurationController < ApplicationController def delete rule=Rule.find(params[:rule_id]) if rule.editable? - rule.enabled=false + rule.status=RULE::STATUS_REMOVED rule.save # it's mandatory to execute 'destroy_all' but not 'delete_all' because active_rule_parameters must diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/index.html.erb index 7105734dc06..1940dba7a8c 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/index.html.erb @@ -119,7 +119,8 @@ <% if enable_modification %>
  • <%= message('bulk_change') -%>: -
    + <%= dropdown_tag "bulk_action", options_for_select([ ["", ""], [message('activate_all'), "activate"], [message('deactivate_all'), "deactivate"] ], ''), { -- 2.39.5