From: Fabrice Bellingard Date: Mon, 19 Dec 2011 16:00:42 +0000 (+0100) Subject: SONAR-2662 Various improvements on action plans X-Git-Tag: 2.13~72 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f63223a280328fab1147c4c048966e5e1792dd74;p=sonarqube.git SONAR-2662 Various improvements on action plans - Should not be possible to link a review to a closed action plan - Display a message when about to close an action plan that has open reviews - Display the date in red if the dead-line is in the past --- diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties index ee60aff5462..a4c273918e9 100644 --- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -426,6 +426,7 @@ action_plans.col.operations=Operations action_plans.no_action_plan=No action plan action_plans.no_reviews_linked_to_action_plan=No reviews linked to this action plan yet. action_plans.confirm_delete=Delete this action plan? Associated reviews will not be deleted. +action_plans.confirm_close=Close this action plan? There are still open reviews linked to it. action_plans.create_new_action_plan=Create a new action plan action_plans.date_format_help=The date should be entered using the following pattern: 'day/month/year'. For instance, '31/12/2011'. action_plans.date_not_valid=Date not valid diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb index 65ac6dfa25e..f0c1c446bb7 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb @@ -190,7 +190,7 @@ class ReviewsController < ApplicationController # GET def action_plan_form @review = Review.find(params[:id]) - @action_plans = ActionPlan.by_project_id(@review.project_id) + @action_plans = ActionPlan.open_by_project_id(@review.project_id) render :partial => 'reviews/action_plan_form' end @@ -382,7 +382,7 @@ class ReviewsController < ApplicationController # GET def violation_action_plan_form @violation = RuleFailure.find(params[:id], :include => ['review', 'snapshot']) - @action_plans = ActionPlan.by_project_id(@violation.snapshot.root_project_id) + @action_plans = ActionPlan.open_by_project_id(@violation.snapshot.root_project_id) render :partial => 'reviews/violation_action_plan_form' end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/action_plan.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/action_plan.rb index 847178da0c7..48a72017e24 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/action_plan.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/action_plan.rb @@ -33,8 +33,8 @@ class ActionPlan < ActiveRecord::Base STATUS_OPEN = 'OPEN' STATUS_CLOSED = 'CLOSED' - def self.by_project_id(project_id) - ActionPlan.find :all, :conditions => ['project_id=?', project_id], :order => :name + def self.open_by_project_id(project_id) + ActionPlan.find :all, :conditions => ['status=? AND project_id=?', STATUS_OPEN, project_id], :order => :name end def user @@ -57,6 +57,14 @@ class ActionPlan < ActiveRecord::Base open_reviews = reviews.select{|r| r.open? || r.reopened?}.size {:total => total_reviews, :open => open_reviews, :resolved => total_reviews-open_reviews} end + + def has_open_reviews? + reviews.select {|r| r.open? || r.reopened?}.size > 0 + end + + def over_due? + dead_line ? dead_line.past? : false + end private diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/index.html.erb index 61b62974a37..60fda96d531 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/action_plans/index.html.erb @@ -1,19 +1,3 @@ - -