Class: Spree::Admin::PaymentImportsController
- Inherits:
-
ResourceController
- Object
- ResourceController
- Spree::Admin::PaymentImportsController
- Defined in:
- app/controllers/spree/admin/payment_imports_controller.rb
Instance Method Summary collapse
Instance Method Details
#clear_import ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/spree/admin/payment_imports_controller.rb', line 38 def clear_import import_id = params[:import_id].presence return invalid_import! if import_id.blank? model_class.where(import_id: import_id).delete_all import = SpreeCmCommissioner::Imports::ImportPaymentReference.find_by(id: import_id) import&.destroy flash[:success] = Spree.t(:successfully_removed, resource: model_class.model_name.human) redirect_to spree.admin_payment_imports_path end |
#import ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/spree/admin/payment_imports_controller.rb', line 21 def import # Check for existing import with the same file name and status done or progress existing_import = SpreeCmCommissioner::Imports::ImportPaymentReference.where( name: imported_file.original_filename, import_type: :aba_payment_reference ).where(status: %i[done progress]).first if existing_import flash[:notice] = Spree.t('admin.import_already_exists', resource: model_class.model_name.human, name: imported_file.original_filename) else import_record = create_import_record! enqueue_import_job(import_record) flash[:success] = Spree.t(:successfully_created, resource: model_class.model_name.human) end redirect_to spree.admin_payment_imports_path end |
#index ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/spree/admin/payment_imports_controller.rb', line 6 def index params[:q] ||= {} @search = model_class.ransack(params[:q]) @import_options = @payment_references = @search.result .order(created_at: :desc) .page(params[:page]) .per(params[:per_page] || 25) end |
#new ⇒ Object
19 |
# File 'app/controllers/spree/admin/payment_imports_controller.rb', line 19 def new; end |