Merge pull request #3413 from LextrendIT/feature/notify_evaluation_comments

notify by email new evaluation comments
This commit is contained in:
Raimond Garcia
2019-06-06 11:29:38 +02:00
committed by GitHub
40 changed files with 319 additions and 54 deletions

View File

@@ -14,7 +14,8 @@ class Admin::SystemEmailsController < Admin::BaseController
direct_message_for_receiver: %w[view edit_info],
direct_message_for_sender: %w[view edit_info],
email_verification: %w[view edit_info],
user_invite: %w[view edit_info]
user_invite: %w[view edit_info],
evaluation_comment: %w[view edit_info]
}
end
@@ -34,6 +35,8 @@ class Admin::SystemEmailsController < Admin::BaseController
load_sample_user
when "user_invite"
@subject = t("mailers.user_invite.subject", org_name: Setting["org_name"])
when "evaluation_comment"
load_sample_valuation_comment
end
end
@@ -97,6 +100,17 @@ class Admin::SystemEmailsController < Admin::BaseController
end
end
def load_sample_valuation_comment
comment = Comment.where(commentable_type: "Budget::Investment").last
if comment
@email = EvaluationCommentEmail.new(comment)
@email_to = @email.to.first
else
redirect_to admin_system_emails_path,
alert: t("admin.system_emails.alert.no_evaluation_comments")
end
end
def load_sample_user
@user = User.last
@token = @user.email_verification_token || SecureRandom.hex

View File

@@ -14,6 +14,7 @@ class CommentsController < ApplicationController
if @comment.save
CommentNotifier.new(comment: @comment).process
add_notification @comment
EvaluationCommentNotifier.new(comment: @comment).process if send_evaluation_notification?
else
render :new
end
@@ -107,4 +108,7 @@ class CommentsController < ApplicationController
end
end
def send_evaluation_notification?
@comment.valuation && Setting["feature.valuation_comment_notification"]
end
end