Add ability to view individual newsletters in admin UI (#39271)
This commit is contained in:
1 parent
a5e763c330
commit
ea5b613796
44 files changed
+248
-72
No files matched your search
@@ -0,0 +1,36 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Admin::EmailSubscriptions::AccountsController < Admin::BaseController
|
||||
before_action :require_enabled!
|
||||
before_action :set_account
|
||||
|
||||
def show
|
||||
authorize :email_subscription, :show?
|
||||
@email_subscriptions_count = EmailSubscription.where(account: @account).count
|
||||
@email_subscriptions = EmailSubscription.where(account: @account).page(params[:page])
|
||||
end
|
||||
|
||||
def enable
|
||||
authorize :email_subscription, :enable?
|
||||
@account.user.settings['email_subscriptions'] = true
|
||||
@account.user.save!
|
||||
redirect_to admin_email_subscriptions_account_path(@account.id)
|
||||
end
|
||||
|
||||
def disable
|
||||
authorize :email_subscription, :disable?
|
||||
@account.user.settings['email_subscriptions'] = false
|
||||
@account.user.save!
|
||||
redirect_to admin_email_subscriptions_account_path(@account.id)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def require_enabled!
|
||||
raise ActionController::RoutingError, 'Feature disabled' unless Rails.application.config.x.email_subscriptions
|
||||
end
|
||||
|
||||
def set_account
|
||||
@account = Account.find(params[:id])
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user