[refs #265] add project_id to comment & fix email notification
This commit is contained in:
parent
0f823bd9f3
commit
13ba125dc0
|
@ -3,7 +3,7 @@ class CommentsController < ApplicationController
|
|||
before_filter :authenticate_user!
|
||||
|
||||
load_resource :project
|
||||
before_filter :set_commentable, :only => [:index, :edit, :create, :update, :destroy]
|
||||
before_filter :set_commentable
|
||||
before_filter :find_comment, :only => [:edit, :update, :destroy]
|
||||
authorize_resource
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ class UserMailer < ActionMailer::Base
|
|||
def new_comment_notification(comment, user)
|
||||
@user = user
|
||||
@comment = comment
|
||||
@comment.helper
|
||||
mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_#{comment.commit_comment? ? 'commit_' : ''}comment_notification")) do |format|
|
||||
format.html
|
||||
end
|
||||
|
|
|
@ -101,7 +101,7 @@ class Ability
|
|||
can([:update, :destroy], Issue) {|issue| issue.user_id == user.id or local_admin?(issue.project)}
|
||||
cannot :manage, Issue, :project => {:has_issues => false} # switch off issues
|
||||
|
||||
can(:create, Comment) {|comment| can? :read, comment.project || comment.commentable.project}
|
||||
can(:create, Comment) {|comment| can? :read, comment.project}
|
||||
can(:update, Comment) {|comment| comment.user_id == user.id or local_admin?(comment.project || comment.commentable.project)}
|
||||
cannot :manage, Comment, :commentable_type => 'Issue', :commentable => {:project => {:has_issues => false}} # switch off issues
|
||||
cannot :manage, RegisterRequest
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
class Comment < ActiveRecord::Base
|
||||
belongs_to :commentable, :polymorphic => true
|
||||
belongs_to :user
|
||||
attr_accessor :project
|
||||
belongs_to :project
|
||||
|
||||
validates :body, :user_id, :commentable_id, :commentable_type, :presence => true
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
class AddProjectToComment < ActiveRecord::Migration
|
||||
def up
|
||||
add_column :comments, :project_id, :integer
|
||||
Subscribe.reset_column_information
|
||||
Comment.where(:commentable_type => 'Grit::Commit').destroy_all
|
||||
Comment.where(:commentable_type => 'Issue').each do |comment|
|
||||
comment.update_attribute(:project_id, comment.commentable.project)
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :comments, :project_id
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue