Class: Railspress::Admin::CmsTransfersController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/railspress/admin/cms_transfers_controller.rb

Instance Method Summary collapse

Instance Method Details

#exportObject



10
11
12
13
14
15
16
17
# File 'app/controllers/railspress/admin/cms_transfers_controller.rb', line 10

def export
  result = ContentExportService.new.call

  send_data result.zip_data,
            filename: result.filename,
            type: "application/zip",
            disposition: "attachment"
end

#importObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/railspress/admin/cms_transfers_controller.rb', line 19

def import
  if params[:file].blank?
    redirect_to admin_cms_transfer_path, alert: "Please select a ZIP file to import."
    return
  end

  @result = ContentImportService.new(params[:file]).call
  load_content_summary

  if @result.errors.any?
    flash.now[:alert] = "Import completed with #{@result.errors.size} error(s)."
  else
    flash.now[:notice] = "Import successful! #{@result.total_processed} items processed."
  end

  render :show
rescue ArgumentError => e
  redirect_to admin_cms_transfer_path, alert: e.message
end

#showObject



6
7
8
# File 'app/controllers/railspress/admin/cms_transfers_controller.rb', line 6

def show
  load_content_summary
end