Class: Workarea::Admin::UnsubscribesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/workarea/admin/unsubscribes_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_user, #find_sort, #wrap_in_view_model, wrap_in_view_model

Methods included from Publishing

#allow_publishing!, #allow_publishing?, #set_publishing_options

Methods included from Visiting

#most_visited

Instance Method Details

#commentableObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/workarea/admin/unsubscribes_controller.rb', line 18

def commentable
  commentable = GlobalID::Locator.locate(params[:commentable_id])

  if @user.present? && commentable&.remove_subscription(@user.id)
    flash[:success] = t(
      'workarea.admin.unsubscribe.flash_messages.commentable_success',
      commentable: commentable.name
    )
  else
    flash[:error] = t('workarea.admin.unsubscribe.flash_messages.commentable_error')
  end

  redirect_to storefront.root_url
end

#status_reportObject



8
9
10
11
12
13
14
15
16
# File 'app/controllers/workarea/admin/unsubscribes_controller.rb', line 8

def status_report
  if @user&.update(status_email_recipient: false)
    flash[:success] = t('workarea.admin.unsubscribe.flash_messages.status_report_success')
  else
    flash[:error] = t('workarea.admin.unsubscribe.flash_messages.status_report_error')
  end

  redirect_to storefront.root_url
end