[refs #54] Fix comments serial_id routing and some logic

This commit is contained in:
konstantin.grabar 2012-01-13 20:07:46 +04:00
parent db0a66846b
commit a1a92e9878
4 changed files with 10 additions and 11 deletions

View File

@ -55,7 +55,7 @@ class CommentsController < ApplicationController
# end
#end
#nil
return Issue.find(params[:issue_id])
return Issue.find_by_serial_id_and_project_id(params[:issue_id], params[:project_id])
end
def set_commentable

View File

@ -12,12 +12,11 @@ class Comment < ActiveRecord::Base
def deliver_new_comment_notification
subscribes = self.commentable.subscribes
subscribes.each do |subscribe|
recipient = subscribe.user
if self.user_id != subscribe.user_id && User.find(recipient).notifier.new_comment_reply && User.find(recipient).notifier.can_notify
if self.commentable.comments.exists?(:user_id => recipient.id)
UserMailer.delay.new_comment_reply_notification(self, recipient)
if self.user_id != subscribe.user_id && User.find(subscribe.user).notifier.new_comment_reply && User.find(subscribe.user).notifier.can_notify
if self.commentable.comments.exists?(:user_id => subscribe.user.id)
UserMailer.delay.new_comment_reply_notification(self, subscribe.user)
else
UserMailer.delay.new_comment_notification(self, recipient)
UserMailer.delay.new_comment_notification(self, subscribe.user)
end
end
end

View File

@ -6,5 +6,5 @@
%h2.title
= t("layout.issues.edit_header")
.inner
= form_for @comment, :url => project_issue_comment_path(@project, @issue.id, @comment), :html => { :class => :form } do |f|
= form_for @comment, :url => project_issue_comment_path(@project, @issue, @comment), :html => { :class => :form } do |f|
= render :partial => "form", :locals => {:f => f}

View File

@ -36,7 +36,7 @@
= t("layout.issues.comments_header")
.inner
%ul.list
- @issue.comments.each do |comment|
- @issue.comments.order(:created_at).each do |comment|
%li
.left
= link_to comment.user.uname, user_path(comment.user.uname)
@ -44,13 +44,13 @@
= comment.body
%br
%br
= link_to t("layout.edit"), edit_project_issue_comment_path(@project, @issue.id, comment) if can? :update, comment
= link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), project_issue_comment_path(@project, @issue.id, comment), :method => "delete", :class => "button", :confirm => t("layout.comments.confirm_delete") if can? :delete, comment
= link_to t("layout.edit"), edit_project_issue_comment_path(@project, @issue, comment) if can? :update, comment
= link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), project_issue_comment_path(@project, @issue, comment), :method => "delete", :class => "button", :confirm => t("layout.comments.confirm_delete") if can? :delete, comment
.block
.content
%h2.title
= t("layout.comments.new_header")
.inner
= form_for :comment, :url => project_issue_comments_path(@project, @issue.id), :method => :post, :html => { :class => :form } do |f|
= form_for :comment, :url => project_issue_comments_path(@project, @issue), :method => :post, :html => { :class => :form } do |f|
= render :partial => "comments/form", :locals => {:f => f}