diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb
index 9b86af520..db8c9228f 100644
--- a/app/helpers/diff_helper.rb
+++ b/app/helpers/diff_helper.rb
@@ -23,12 +23,12 @@ module DiffHelper
#include Git::Diff::InlineCallback
def render_diff(diff, diff_counter)
diff_display ||= Diff::Display::Unified.new(diff.diff)
- path = if @pull
+ url = if @pull
@pull.id ? polymorphic_path([@project, @pull]) : ''
elsif @commit
commit_path @project, @commit
end
- prepare(diff, path)
+ prepare(diff, url, diff_counter)
res = "
"
res += ""
@@ -41,9 +41,9 @@ module DiffHelper
########################################################
# FIXME: Just to dev, remove to lib
########################################################
- def prepare(diff, comments, url, diff_counter)
- @num_line, @url, @diff_counter = -1, url, diff_counter
- @line_comments = @comments.select{|c| c.data.try('[]', :path) == @path}
+ def prepare(diff, url, diff_counter)
+ @num_line, @filepath, @url, @diff_counter = -1, diff.a_path, url, diff_counter
+ @line_comments = @comments.select{|c| c.data.try('[]', :path) == @filepath}
end
def headerline(line)
@@ -212,7 +212,7 @@ module DiffHelper
end
def line_comment
- link_to image_tag('line_comment.png', :alt => t('layout.comments.new_header')), new_line_commit_comment_path(@project, @commit, :path => @diff.a_path, :line => @num_line), :class => 'add_line-comment'
+ link_to image_tag('line_comment.png', :alt => t('layout.comments.new_header')), new_line_commit_comment_path(@project, @commit, :path => @filepath, :line => @num_line), :class => 'add_line-comment'
end
def render_line_comments
diff --git a/app/models/ability.rb b/app/models/ability.rb
index da812b061..57e4999b5 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -132,9 +132,7 @@ class Ability
can([:create, :new_line], Comment) {|comment| can? :read, comment.project}
can([:update, :destroy], Comment) {|comment| comment.user == user or comment.project.owner == user or local_admin?(comment.project)}
- cannot :manage, Comment do |c|
- c.commentable_type == 'Issue' && !c.project.has_issues && !c.commentable.pull_request # when switch off issues
- end
+ cannot :manage, Comment, :commentable_type => 'Issue', :project => {:has_issues => false}
end
# Shared cannot rights for all users (registered, admin)
diff --git a/app/views/projects/comments/_add.html.haml b/app/views/projects/comments/_add.html.haml
index 513a8a666..132f81541 100644
--- a/app/views/projects/comments/_add.html.haml
+++ b/app/views/projects/comments/_add.html.haml
@@ -1,6 +1,5 @@
#open-comment.comment.view
=render 'projects/comments/button_md_help'
- =link_to t('layout.comments.md_cheatsheet_header'), '#md_help', 'data-toggle' => 'modal', :style => 'float:right;'
%h3.tmargin0= t("layout.comments.new_header")
- if Comment.issue_comment?(commentable.class)
- new_path = project_issue_comments_path(project, commentable)
diff --git a/app/views/projects/comments/_button_md_help.html.haml b/app/views/projects/comments/_button_md_help.html.haml
index e69de29bb..3cc040988 100644
--- a/app/views/projects/comments/_button_md_help.html.haml
+++ b/app/views/projects/comments/_button_md_help.html.haml
@@ -0,0 +1,2 @@
+=link_to t('layout.comments.md_cheatsheet_header'), '#md_help', 'data-toggle' => 'modal', :style => 'float:right;'
+
diff --git a/app/views/projects/comments/_line_list.html.haml b/app/views/projects/comments/_line_list.html.haml
index 9b3113d58..929c219ca 100644
--- a/app/views/projects/comments/_line_list.html.haml
+++ b/app/views/projects/comments/_line_list.html.haml
@@ -1,11 +1,3 @@
- list.each do |comment|
.inline-comments
- - CommentPresenter.present(comment, :project => project, :commentable => commentable) do |presenter|
- = render 'shared/feed_message', :presenter => presenter
- #open-comment.comment.hidden{:class => "comment-#{comment.id}"}
- %h3.tmargin0= t("layout.comments.edit_header")
- = form_for comment, :url => project_commentable_comment_path(project, commentable, comment), :html => { :class => 'form edit_comment' } do |f|
- = render "projects/comments/form", :f => f, :id => "edit_#{comment.id}"
- .comment-left
- =link_to t('layout.cancel'), '#', :id => "comment-#{comment.id}", :class => 'cancel_edit_comment button'
- .both
+ = render 'projects/comments/comment', :comment => comment, :project => project, :commentable => commentable
diff --git a/db/migrate/20121005100158_add_data_to_comments.rb b/db/migrate/20121005100158_add_data_to_comments.rb
new file mode 100644
index 000000000..c33ed6a8b
--- /dev/null
+++ b/db/migrate/20121005100158_add_data_to_comments.rb
@@ -0,0 +1,5 @@
+class AddDataToComments < ActiveRecord::Migration
+ def change
+ add_column :comments, :data, :text
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 0d2a29289..bd9ee3cdb 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20121003154246) do
+ActiveRecord::Schema.define(:version => 20121005100158) do
create_table "activity_feeds", :force => true do |t|
t.integer "user_id", :null => false
@@ -146,6 +146,7 @@ ActiveRecord::Schema.define(:version => 20121003154246) do
t.datetime "updated_at", :null => false
t.decimal "commentable_id", :precision => 50, :scale => 0
t.integer "project_id"
+ t.text "data"
end
create_table "event_logs", :force => true do |t|
diff --git a/lib/ext/git/inline_callback.rb b/lib/ext/git/inline_callback.rb
index 896672b6d..c95b5913a 100644
--- a/lib/ext/git/inline_callback.rb
+++ b/lib/ext/git/inline_callback.rb
@@ -2,8 +2,8 @@
module Git
module Diff
class InlineCallback < ::Diff::Renderer::Base
- def initialize diff, comments, url, diff_counter
- @num_line, @url, @diff_counter = -1, url, diff_counter
+ def initialize diff, url, diff_counter
+ @num_line, @filepath, @url, @diff_counter = -1, diff.a_path, url, diff_counter
@line_comments = @comments.select{|c| c.data.try('[]', :path) == @path}
end
@@ -173,7 +173,7 @@ module Git
end
def line_comment
- link_to image_tag('line_comment.png', :alt => t('layout.comments.new_header')), new_line_commit_comment_path(@project, @commit, :path => @diff.a_path, :line => @num_line), :class => 'add_line-comment'
+ link_to image_tag('line_comment.png', :alt => t('layout.comments.new_header')), new_line_commit_comment_path(@project, @commit, :path => @filepath, :line => @num_line), :class => 'add_line-comment'
end
def render_line_comments