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
|
||||
@@ -1,6 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Admin::EmailSubscriptionsController < Admin::BaseController
|
||||
before_action :set_email_subscription, only: :destroy
|
||||
|
||||
def index
|
||||
authorize :email_subscription, :index?
|
||||
|
||||
@@ -9,6 +11,12 @@ class Admin::EmailSubscriptionsController < Admin::BaseController
|
||||
@accounts = Account.local.where.associated(:email_subscriptions).includes(:user)
|
||||
end
|
||||
|
||||
def destroy
|
||||
authorize :email_subscription, :destroy?
|
||||
@email_subscription.destroy!
|
||||
redirect_to admin_email_subscriptions_account_path(@email_subscription.account_id)
|
||||
end
|
||||
|
||||
def disable
|
||||
authorize :email_subscription, :disable?
|
||||
Setting.email_subscriptions = false
|
||||
@@ -20,4 +28,10 @@ class Admin::EmailSubscriptionsController < Admin::BaseController
|
||||
Admin::EmailSubscriptionsPurgeWorker.perform_async
|
||||
redirect_to admin_email_subscriptions_path, notice: I18n.t('admin.email_subscriptions.purged_msg')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_email_subscription
|
||||
@email_subscription = EmailSubscription.find(params[:id])
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user