Merge pull request #251 from warpc/194-tracker

[Refs #194] Add comments to Issue and fix bugs
This commit is contained in:
Vladimir Sharshov 2012-03-01 11:37:34 -08:00
commit 86581a6fdf
9 changed files with 28 additions and 13 deletions

View File

@ -271,13 +271,13 @@ article div.file table {
resize: none;
}
#repo-wrapper div.comment div.comment-left {
div.comment div.comment-left {
float: left;
font-size: 12px;
margin-top: 4px;
}
#repo-wrapper div.comment div.comment-right {
div.comment div.comment-right {
float: right;
}

View File

@ -6,6 +6,8 @@ class Comment < ActiveRecord::Base
validates :body, :user_id, :commentable_id, :commentable_type, :presence => true
default_scope order('created_at')
after_create :invoke_helper, :if => "commentable_type == 'Grit::Commit'"
after_create :subscribe_users
after_create {|c| Subscribe.new_comment_notification(c)}

View File

@ -193,7 +193,7 @@ class Project < ActiveRecord::Base
class << self
def commit_comments(commit, project)
comments = Comment.where(:commentable_id => commit.id.hex, :commentable_type => 'Grit::Commit').order(:created_at)
comments = Comment.where(:commentable_id => commit.id.hex, :commentable_type => 'Grit::Commit')
comments.each {|x| x.project = project; x.helper}
end
end

View File

@ -46,6 +46,7 @@ class CommentPresenter < ApplicationPresenter
res << link_to(t("layout.delete"), dp, :method => "delete",
:confirm => t("layout.comments.confirm_delete")).html_safe
end
res
end
def header

View File

@ -1,20 +1,27 @@
#open-comment.comment.view
%h3.tmargin0= t("layout.comments.new_header")
- new_path = project_issue_comments_path(project, commentable) if commentable.class == Issue
- new_path = project_commit_comments_path(project, commentable) if commentable.class == Grit::Commit
- if commentable.class == Issue
- new_path = project_issue_comments_path(project, commentable)
- is_subscribed = commentable.subscribes.exists?(:user_id => current_user.id)
- subscribe_path = is_subscribed ? project_issue_subscribe_path(project, commentable, current_user.id) : project_issue_subscribes_path(project, commentable)
- else commentable.class == Grit::Commit
- new_path = project_commit_comments_path(project, commentable)
- is_subscribed = Subscribe.subscribed_to_commit?(project, current_user, commentable)
- subscribe_path = is_subscribed ? unsubscribe_commit_path(project, commentable) : subscribe_commit_path(project, commentable)
= form_for :comment, :url => new_path, :method => :post, :html => { :class => :form } do |f|
= render :partial => "comments/form", :locals => {:f => f}
.comment-left
= t("layout.comments.notifications_are")
%span.bold
- if Subscribe.subscribed_to_commit?(@project, current_user, @commit)
- if is_subscribed
= t("layout.turned_on")\
- else
= t("layout.turned_off")\
\.
- if Subscribe.subscribed_to_commit?(@project, current_user, @commit)
= link_to t('layout.commits.unsubscribe_btn'), unsubscribe_commit_path(@project, @commit), :method => :delete
- if is_subscribed
= link_to t('layout.commits.unsubscribe_btn'), subscribe_path, :method => :delete
- else
= link_to t('layout.commits.subscribe_btn'), subscribe_commit_path(@project, @commit), :method => :post
= link_to t('layout.commits.subscribe_btn'), subscribe_path, :method => :post
.both

View File

@ -1,10 +1,10 @@
.block
.secondary-navigation
%ul.wat-cf
%li.first= link_to t(@comment.commentable_type == 'Grit::Commit' ? "layout.git.repositories.commits" : "layout.issues.list"), @commentable_path
%li.first= link_to t("layout.comments.back"), @commentable_path
.content
%h2.title
= t("layout.#{@comment.commentable_type == 'Grit::Commit' ? 'comments' : 'issues'}.edit_header")
= t("layout.comments.edit_header")
.inner
= form_for @comment, :url => @update_url, :html => { :class => :form } do |f|
= render :partial => "form", :locals => {:f => f}

View File

@ -26,6 +26,9 @@
.both
=f.submit t('layout.update'), :id => 'update_issue_content'
=link_to t('layout.issues.cancel_button'), '#', :id => 'cancel_edit_issue_content', :class => 'button'
.hr
%br
=render :partial => 'issues/status'
= render :partial => "comments/list", :locals => {:list => @issue.comments, :project => @project, :commentable => @issue}
%br
= render :partial => "comments/add", :locals => {:project => @project, :commentable => @issue}

View File

@ -4,3 +4,4 @@ en:
has_commented: "adds a note"
notifications_are: "Notifications for new comments are"
comments_header: "Comments"
back: 'Back'

View File

@ -4,3 +4,4 @@ ru:
has_commented: "оставил комментарий"
notifications_are: "Уведомления о последующих комментариях"
comments_header: "Комментарии"
back: 'Назад'