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:
Bertocq
2018-04-18 16:12:38 +02:00
committed by decabeza
parent 5c726e0949
commit eb0919d978
8 changed files with 123 additions and 10 deletions

View File

@@ -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