diff options
author | Fabrice Bellingard <bellingard@gmail.com> | 2011-04-06 12:22:52 +0200 |
---|---|---|
committer | Fabrice Bellingard <bellingard@gmail.com> | 2011-04-20 08:49:56 +0200 |
commit | 7ef58aa56b677defefbbff6172fedf393a57702f (patch) | |
tree | 72c31f3353c2cbf3c1ba083aea9d70a3e6665fe8 /sonar-server/src | |
parent | 7cb5ce119e44197ff9fbcc3b9e804335e781a344 (diff) | |
download | sonarqube-7ef58aa56b677defefbbff6172fedf393a57702f.tar.gz sonarqube-7ef58aa56b677defefbbff6172fedf393a57702f.zip |
TEMP commit before changing review_data into review_comment
Diffstat (limited to 'sonar-server/src')
11 files changed, 148 insertions, 22 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb index da4dbd299fb..41eb70554b7 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb @@ -195,7 +195,7 @@ class ResourceController < ApplicationController end end - RuleFailure.find(:all, :include => 'rule', :conditions => [conditions] + values, :order => 'failure_level DESC').each do |violation| + RuleFailure.find(:all, :include => ['rule', 'reviews', { 'reviews' => 'review_data' } ], :conditions => [conditions] + values, :order => 'failure_level DESC').each do |violation| # sorted by severity => from blocker to info if violation.line && violation.line>0 && @lines @lines[violation.line-1].add_violation(violation) 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 new file mode 100644 index 00000000000..e78b99580be --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb @@ -0,0 +1,54 @@ +# +# 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_CONFIGURATION + + def index + end + + def form + @review = Review.new + @review.rule_failure_id = params[:violation_id] + @review.user = current_user + @review_data = ReviewData.new + @review_data.user = current_user + @review_data.review = @review + @review_data.review_text = "Enter your review here" + render "_form", :layout => false + end + + def create + review = Review.new(params[:review]) + review.user = current_user + review.save + review_data = ReviewData.new(params[:review_data]) + review_data.user = current_user + review_data.review_id = review.id + review_data.save + #render "_view", :layout => false + end + + def cancel_create + render :nothing => true + end + +end 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 c271a3115d6..eea61dffc9c 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 @@ -21,15 +21,9 @@ class Review < ActiveRecord::Base belongs_to :user belongs_to :rule_failure belongs_to :resource, :class_name => 'Project', :foreign_key => 'resource_id' - has_many :review_data, :order => created_at, :dependent => :destroy + has_many :review_data, :order => "created_at", :dependent => :destroy validates_presence_of :user validates_presence_of :review_type validates_presence_of :status - validate :review_must_have_at_least_one_comment - - def review_must_have_at_least_one_comment - errors.add("A review must have at least one comment.") if - review_data.length < 1 - end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/review_data.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/review_data.rb index 7933d7f8187..a0b250ea30d 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/review_data.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/review_data.rb @@ -18,6 +18,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 # class ReviewData < ActiveRecord::Base + set_table_name :review_data + belongs_to :user belongs_to :review validates_presence_of :user diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb index 3b4886f2dad..3cac05b8463 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb @@ -22,6 +22,7 @@ class RuleFailure < ActiveRecord::Base belongs_to :rule belongs_to :snapshot + has_many :reviews, :order => "created_at" def to_hash_json json = {} diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb index 4ede0c41398..678064fd265 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb @@ -1,14 +1,40 @@ <div class="violation"> -<img src="<%= ApplicationController.root_context -%>/images/priority/<%=violation.failure_level-%>.png"/> - -<span class="rulename"><a onclick="window.open(this.href,'rule','height=800,width=900,scrollbars=1,resizable=1');return false;" href="<%= url_for :controller => 'rules', :action => 'show', :id => violation.rule.key, :layout => 'false' -%>"><%= h(violation.rule.name) -%></a></span> - » -<%= violation_html_message(violation) -%> -<% - if violation.created_at - duration=Date.today - violation.created_at.to_date - -%> - <span class="violation_date"><%= duration==0 ? 'today' : "#{duration} days ago" -%></span> -<% end %> - </div>
\ No newline at end of file + <table> + <tr> + + <td width="30px" valign="top"> + <% if current_user %> + <%= link_to_remote(image_tag("add.png"), + :update => "review" + violation.id.to_s , + :url => { :controller => "reviews", :action => "form", :violation_id => violation.id }) -%> + <% end %> + </td> + + <td> + <img src="<%= ApplicationController.root_context -%>/images/priority/<%=violation.failure_level-%>.png"/> + + <span class="rulename"><a onclick="window.open(this.href,'rule','height=800,width=900,scrollbars=1,resizable=1');return false;" href="<%= url_for :controller => 'rules', :action => 'show', :id => violation.rule.key, :layout => 'false' -%>"><%= h(violation.rule.name) -%></a></span> + » + <%= h(violation.message) -%> + <% + if violation.created_at + duration=Date.today - violation.created_at.to_date + %> + <span class="violation_date"><%= duration==0 ? 'today' : "#{duration} days ago" -%></span> + <% end %> + + <div id="review<%= violation.id -%>" style="padding:5px; background:white"> + <% unless violation.reviews.blank? + violation.reviews.each do |review| + %> + <%= render :partial => "reviews/view", :locals => { :review => review } %> + <% + end + end + %> + </div> + </td> + + </tr> + </table> +</div> 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 new file mode 100644 index 00000000000..b26e64c846a --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_form.html.erb @@ -0,0 +1,23 @@ +<% form_for :review, @review, :url => { :action => 'create', :id => @review.id } do |f| %> + <%= f.hidden_field :rule_failure_id %> + Review by: <%= @review.user.login -%> + <br/> + Review type: <%= f.text_field :review_type %> + <br/> + Status: <%= f.text_field :status %> + <br/> + Severity: <%= f.text_field :severity %> + <br/> + External Link: <%= f.text_field :external_link %> + <br/> + Comment: + <br/> + <%= text_area :review_data, :review_text, :rows => 10 %> + <br/> + <%= submit_to_remote 'create_btn', 'Create review', + :url => { :action => 'create', :id => @review.id }, + :update => { :success => "review" + @review.rule_failure_id.to_s, :failure => "fail" } %> + <%= submit_to_remote 'cancel_btn', 'Cancel', + :url => { :action => 'cancel_create' }, + :update => { :success => "review" + @review.rule_failure_id.to_s } %> +<% end %>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_view.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_view.html.erb new file mode 100644 index 00000000000..1541b84399b --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_view.html.erb @@ -0,0 +1,24 @@ +<div> + Review Id: <%= review.id -%> + <br/> + Review Id: <%= review.user.name -%> + <br/> + Review type: <%= review.review_type -%> + <br/> + Status: <%= review.status -%> + <br/> + Severity: <%= review.severity -%> + <br/> + External Link: <%= review.external_link -%> + <br/> + + <% unless review.review_data.blank? + review.review_data.each do |review_data| + %> + Comment: <%= review_data.review_text -%> + <br/> + <% + end + end + %> +</div>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/create.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/create.html.erb new file mode 100644 index 00000000000..5ddd60c2e98 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/create.html.erb @@ -0,0 +1 @@ +Created!
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/index.html.erb new file mode 100644 index 00000000000..c95d9de3008 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/index.html.erb @@ -0,0 +1 @@ +Hello !
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/190_create_review.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/190_create_review.rb index a7a03a251fd..378b69db968 100644 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/190_create_review.rb +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/190_create_review.rb @@ -29,7 +29,7 @@ class CreateReview < ActiveRecord::Migration t.column 'user_id', :integer, :null => true t.column 'review_type', :string, :null => true, :limit => 10 t.column 'status', :string, :null => true, :limit => 10 - t.column 'severity', :integer, :null => true + t.column 'severity', :string, :null => true, :limit => 10 t.column 'external_link', :string, :null => true, :limit => 200 t.column 'rule_failure_id', :integer, :null => true t.column 'resource_id', :integer, :null => true |