Class: Lcms::Engine::Admin::DocumentsController

Inherits:
AdminController show all
Includes:
GoogleCredentials, PathHelper, Reimportable
Defined in:
app/controllers/lcms/engine/admin/documents_controller.rb

Constant Summary

Constants inherited from AdminController

AdminController::RE_GOOGLE_FOLDER

Instance Method Summary collapse

Methods included from PathHelper

#dynamic_document_path, #dynamic_material_path, #dynamic_path

Methods inherited from AdminController

settings

Instance Method Details

#createObject



20
21
22
23
24
25
26
# File 'app/controllers/lcms/engine/admin/documents_controller.rb', line 20

def create
  @document = DocumentForm.new(form_params.except(:async, :with_materials))

  return create_multiple if form_params[:link].match?(RE_GOOGLE_FOLDER)

  form_params[:async].to_i.zero? ? create_sync : create_async
end

#destroyObject



28
29
30
31
32
# File 'app/controllers/lcms/engine/admin/documents_controller.rb', line 28

def destroy
  @document = Document.find(params[:id])
  @document.destroy
  redirect_to lcms_engine.admin_documents_path(query: @query_params), notice: t('.success')
end

#destroy_selectedObject



34
35
36
37
# File 'app/controllers/lcms/engine/admin/documents_controller.rb', line 34

def destroy_selected
  count = @documents.destroy_all.count
  redirect_to lcms_engine.admin_documents_path(query: @query_params), notice: t('.success', count: count)
end

#import_statusObject



39
40
41
42
# File 'app/controllers/lcms/engine/admin/documents_controller.rb', line 39

def import_status
  data = import_status_for DocumentGenerator.document_parse_job
  render json: data, status: :ok
end

#indexObject



14
15
16
17
18
# File 'app/controllers/lcms/engine/admin/documents_controller.rb', line 14

def index
  @query = OpenStruct.new @query_params # rubocop:disable Style/OpenStructUse
  @documents = DocTemplate.config['queries']['document'].constantize.call(@query, page: params[:page])
  render_customized_view
end

#newObject



44
45
46
# File 'app/controllers/lcms/engine/admin/documents_controller.rb', line 44

def new
  @document = DocumentForm.new
end

#reimport_selectedObject



48
49
50
51
# File 'app/controllers/lcms/engine/admin/documents_controller.rb', line 48

def reimport_selected
  bulk_import @documents
  render :import
end