Sha256: b38e157e1693c904fb567af50acc30755b156eb28d0b4c7600b90bd4f4bda6d4

Contents?: true

Size: 882 Bytes

Versions: 7

Compression:

Stored size: 882 Bytes

Contents

require 'slim'
require 'cm_admin/version'
require 'cm_admin/engine'
require 'cm_admin/model'
require 'cm_admin/view_helpers'

module CmAdmin
  class ExportsController < ApplicationController
    before_action :set_current_user_permission

    def send_export_email
      export_params = params.permit(:select_all, :class_name, :associated_class_name, :parent_id, :child_records,
                                    :action_name, :filters, columns: []).to_h
      associated_model_name = params[:associated_class_name].presence || params[:class_name]
      expires_at = DateTime.now + 1.day
      FileExport.create!(associated_model_name:, exported_by: Current.user, expires_at:, params: export_params)
    end

    private

    def set_current_user_permission
      CmCurrent.user_permissions = Current.user.cm_role.cm_permissions if Current.user.cm_role.present?
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cm-admin-4.4.8 app/controllers/cm_admin/exports_controller.rb
cm-admin-4.4.6 app/controllers/cm_admin/exports_controller.rb
cm-admin-4.4.1 app/controllers/cm_admin/exports_controller.rb
cm-admin-4.4.0 app/controllers/cm_admin/exports_controller.rb
cm-admin-4.3.0 app/controllers/cm_admin/exports_controller.rb
cm-admin-4.2.1 app/controllers/cm_admin/exports_controller.rb
cm-admin-4.2.0 app/controllers/cm_admin/exports_controller.rb