aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorFabrice Bellingard <bellingard@gmail.com>2011-04-10 15:29:03 +0200
committerFabrice Bellingard <bellingard@gmail.com>2011-04-20 08:49:57 +0200
commite45c2a5959eec47d06e15ec6db101f0975ad0bb0 (patch)
tree0a5e39fa2d63f13e3100ca4147b87d5c5080ad20 /sonar-server
parent0c84e708498524c37ba00e941a1d63e04a3a2607 (diff)
downloadsonarqube-e45c2a5959eec47d06e15ec6db101f0975ad0bb0.tar.gz
sonarqube-e45c2a5959eec47d06e15ec6db101f0975ad0bb0.zip
[SONAR-1973] Fix a wrong link
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb274
1 files changed, 137 insertions, 137 deletions
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 8dea0fb9b63..ac66e350e0e 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
@@ -1,137 +1,137 @@
-#
-# Sonar, entreprise quality control tool.
-# Copyright (C) 2008-2011 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
-#
-
-class ReviewsController < ApplicationController
-
- SECTION=Navigation::SECTION_HOME
-
- verify :method => :post, :only => [ :create, :create_comment ], :redirect_to => { :action => :error_not_post }
-
- def index
- init_params
-
- @reviews = []
- unless params.blank?
- @reviews = Review.find :all, :conditions => ['status=?', @statuses]
- end
- end
-
- def list
- reviews = findReviewsForRuleFailure params[:rule_failure_id]
- render :partial => "index", :locals => { :reviews => reviews }
- end
-
- def form
- @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"
- end
-
- def form_comment
- @review_comment = ReviewComment.new
- @review_comment.user = current_user
- @review_comment.review_id = params[:review_id]
- @review_comment.review_text = ""
- @rule_failure_id = params[:rule_failure_id]
- render :partial => "form_comment"
- end
-
- def create
- unless hasRightsToCreate? params[:review][:rule_failure_id]
- render :text => "<b>Cannot create the review</b> : access denied."
- return
- end
-
- @review = Review.new(params[:review])
- @review.user = current_user
- @review.status = Review.default_status
- @review.review_type = Review.default_type
- @review_comment = ReviewComment.new(params[:review_comment])
- @review_comment.user = current_user
- @review.review_comments << @review_comment
- if @review.valid?
- @review.save
- @reviews = findReviewsForRuleFailure @review.rule_failure_id
- end
- render "create_result"
- end
-
- def create_comment
- unless hasRightsToCreate? params[:rule_failure_id]
- render :text => "<b>Cannot create the comment</b> : access denied."
- return
- end
-
- @review_comment = ReviewComment.new(params[:review_comment])
- @review_comment.user = current_user
- @rule_failure_id = params[:rule_failure_id]
- if @review_comment.valid?
- @review_comment.save
- @reviews = findReviewsForRuleFailure @rule_failure_id
- end
- render "create_comment_result"
- end
-
-
- ## -------------- PRIVATE -------------- ##
- private
-
- def init_params
- users = User.find :all
- @user_names = [["Any", ""]]
- users.each do |user|
- @user_names << [user.name, user.id.to_s]
- end
- @review_authors = filter_any(params[:review_authors]) || [""]
- @comment_authors = filter_any(params[:comment_authors]) || [""]
- @severities = filter_any(params[:severities]) || [""]
- @statuses = filter_any(params[:statuses]) || ["open"]
- end
-
- def filter_any(array)
- if array && array.size>1 && array.include?('')
- array=[''] #keep only 'any'
- end
- array
- end
-
- def findReviewsForRuleFailure ( rule_failure_id )
- return Review.find :all, :conditions => ['rule_failure_id=?', rule_failure_id]
- end
-
- def hasRightsToCreate? ( rule_failure_id )
- return false unless current_user
-
- project = RuleFailure.find( rule_failure_id, :include => ['snapshot'] ).snapshot.root_project
- unless has_role?(:user, project)
- return false
- end
- return true
- end
-
- def error_not_post
- render :text => "Create actions must use POST method."
- end
-
-end
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2011 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
+#
+
+class ReviewsController < ApplicationController
+
+ SECTION=Navigation::SECTION_HOME
+
+ verify :method => :post, :only => [ :create, :create_comment ], :redirect_to => { :action => :error_not_post }
+
+ def index
+ init_params
+
+ @reviews = []
+ unless params.blank?
+ @reviews = Review.find :all, :conditions => ['status=?', @statuses]
+ end
+ end
+
+ def list
+ reviews = findReviewsForRuleFailure params[:rule_failure_id]
+ render :partial => "list", :locals => { :reviews => reviews }
+ end
+
+ def form
+ @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"
+ end
+
+ def form_comment
+ @review_comment = ReviewComment.new
+ @review_comment.user = current_user
+ @review_comment.review_id = params[:review_id]
+ @review_comment.review_text = ""
+ @rule_failure_id = params[:rule_failure_id]
+ render :partial => "form_comment"
+ end
+
+ def create
+ unless hasRightsToCreate? params[:review][:rule_failure_id]
+ render :text => "<b>Cannot create the review</b> : access denied."
+ return
+ end
+
+ @review = Review.new(params[:review])
+ @review.user = current_user
+ @review.status = Review.default_status
+ @review.review_type = Review.default_type
+ @review_comment = ReviewComment.new(params[:review_comment])
+ @review_comment.user = current_user
+ @review.review_comments << @review_comment
+ if @review.valid?
+ @review.save
+ @reviews = findReviewsForRuleFailure @review.rule_failure_id
+ end
+ render "create_result"
+ end
+
+ def create_comment
+ unless hasRightsToCreate? params[:rule_failure_id]
+ render :text => "<b>Cannot create the comment</b> : access denied."
+ return
+ end
+
+ @review_comment = ReviewComment.new(params[:review_comment])
+ @review_comment.user = current_user
+ @rule_failure_id = params[:rule_failure_id]
+ if @review_comment.valid?
+ @review_comment.save
+ @reviews = findReviewsForRuleFailure @rule_failure_id
+ end
+ render "create_comment_result"
+ end
+
+
+ ## -------------- PRIVATE -------------- ##
+ private
+
+ def init_params
+ users = User.find :all
+ @user_names = [["Any", ""]]
+ users.each do |user|
+ @user_names << [user.name, user.id.to_s]
+ end
+ @review_authors = filter_any(params[:review_authors]) || [""]
+ @comment_authors = filter_any(params[:comment_authors]) || [""]
+ @severities = filter_any(params[:severities]) || [""]
+ @statuses = filter_any(params[:statuses]) || ["open"]
+ end
+
+ def filter_any(array)
+ if array && array.size>1 && array.include?('')
+ array=[''] #keep only 'any'
+ end
+ array
+ end
+
+ def findReviewsForRuleFailure ( rule_failure_id )
+ return Review.find :all, :conditions => ['rule_failure_id=?', rule_failure_id]
+ end
+
+ def hasRightsToCreate? ( rule_failure_id )
+ return false unless current_user
+
+ project = RuleFailure.find( rule_failure_id, :include => ['snapshot'] ).snapshot.root_project
+ unless has_role?(:user, project)
+ return false
+ end
+ return true
+ end
+
+ def error_not_post
+ render :text => "Create actions must use POST method."
+ end
+
+end