Add Preview Pending action to Admin System Emails
Some system emails need to be manually reviewed before being sent. This new action allows admins to see a preview of all Pending to be sent Proposal Notification Digest messages.
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
class Admin::SystemEmailsController < Admin::BaseController
|
||||
|
||||
before_action :load_system_email, only: [:view]
|
||||
before_action :load_system_email, only: [:view, :preview_pending]
|
||||
|
||||
def index
|
||||
@system_emails = %w(proposal_notification_digest)
|
||||
@system_emails = {
|
||||
proposal_notification_digest: %w(view preview_pending)
|
||||
}
|
||||
end
|
||||
|
||||
def view
|
||||
@@ -14,9 +16,22 @@ class Admin::SystemEmailsController < Admin::BaseController
|
||||
end
|
||||
end
|
||||
|
||||
def preview_pending
|
||||
case @system_email
|
||||
when "proposal_notification_digest"
|
||||
@previews = ProposalNotification.where(id: unsent_proposal_notifications_ids)
|
||||
.page(params[:page])
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_system_email
|
||||
@system_email = params[:system_email_id]
|
||||
end
|
||||
|
||||
def unsent_proposal_notifications_ids
|
||||
Notification.where(notifiable_type: "ProposalNotification", emailed_at: nil)
|
||||
.group(:notifiable_id).count.keys
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user