From 83216f69146cc4a0ab71fb7b4883062bc74c3872 Mon Sep 17 00:00:00 2001 From: Fabrice Bellingard Date: Thu, 7 Apr 2011 18:58:26 +0200 Subject: [PATCH] [SONAR-1973] Adds select box for severity --- .../app/controllers/reviews_controller.rb | 1 + .../main/webapp/WEB-INF/app/models/review.rb | 21 +++++++++++++++++++ .../WEB-INF/app/views/reviews/_form.html.erb | 3 ++- 3 files changed, 24 insertions(+), 1 deletion(-) 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 93e3f46137d..91e0a489f6d 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 @@ -33,6 +33,7 @@ class ReviewsController < ApplicationController @review = Review.new @review.rule_failure_id = params[:violation_id] @review.user = current_user + @review.severity = Review.default_severity @review_comment = ReviewComment.new @review_comment.review_text = "" render :partial => "form" diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb index bdaaa65e512..13ee58b80fe 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb @@ -26,4 +26,25 @@ class Review < ActiveRecord::Base validates_presence_of :review_type, :message => "can't be empty" validates_presence_of :status, :message => "can't be empty" + INFO = "info" + MINOR = "minor" + MAJOR = "major" + CRITICAL = "critical" + BLOCKER = "blocker" + + + def self.default_severity + return MAJOR + end + + def self.severity_options + severity_ops = [] + severity_ops << ["Info", INFO] + severity_ops << ["Minor", MINOR] + severity_ops << ["Major", MAJOR] + severity_ops << ["Critical", CRITICAL] + severity_ops << ["Blocker", BLOCKER] + return severity_ops + end + end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_form.html.erb index 0cd174a4d7c..ffd94f09f46 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_form.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_form.html.erb @@ -3,7 +3,8 @@ <%= f.hidden_field :rule_failure_id %> Review made by: <%= @review.user.name -%>
- Severity: <%= f.text_field :severity %> + Severity: + <%= select_tag "review[severity]", options_for_select(Review.severity_options, @review.severity) %>
Comment:
-- 2.39.5