Class: MassSearch::CustomerDeleteLeadsWorker
- Inherits:
-
Object
- Object
- MassSearch::CustomerDeleteLeadsWorker
- Includes:
- MassSearchWorker
- Defined in:
- app/workers/mass_search/customer_delete_leads_worker.rb
Overview
Destroys Customers that are in lead_qualify or guest state.
Requires user to have admin/sales_director/sales_manager role.
Constant Summary collapse
- ALLOWED_ROLES =
%w[admin sales_director sales_manager].freeze
- DELETABLE_STATES =
%w[lead_qualify guest].freeze
Instance Method Summary collapse
Instance Method Details
#build_enumerator(args, cursor:) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'app/workers/mass_search/customer_delete_leads_worker.rb', line 11 def build_enumerator(args, cursor:) super unless @user&.has_role?(ALLOWED_ROLES) @unauthorised = true return active_record_records_enumerator(@search.search_results.none, cursor: cursor) end active_record_records_enumerator(@search.search_results, cursor: cursor) end |
#on_complete ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'app/workers/mass_search/customer_delete_leads_worker.rb', line 21 def on_complete if @unauthorised store error_message: 'Unable to delete leads: permissions not granted.', redirect_to: Rails.application.routes.url_helpers.search_path(@search_id) else super end end |