Class: Tasks::Bibliography::VerbatimReferenceController

Inherits:
ApplicationController
  • Object
show all
Includes:
TaskControllerConfiguration
Defined in:
app/controllers/tasks/bibliography/verbatim_reference_controller.rb

Instance Method Summary collapse

Methods included from TaskControllerConfiguration

#set_is_task_controller

Instance Method Details

#citation_paramObject (protected)



50
51
52
53
54
55
56
# File 'app/controllers/tasks/bibliography/verbatim_reference_controller.rb', line 50

def citation_param
  begin
    params.require(:citation)
  rescue ActionController::ParameterMissing
    nil
  end
end

#create_bibtexObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/tasks/bibliography/verbatim_reference_controller.rb', line 28

def create_bibtex
  @source = TaxonWorks::Vendor::Serrano.new_from_citation(citation: params[:in_cite])
  @source.project_sources_attributes = [{project_id: sessions_current_project_id}]

  if @source.save
    flash[:notice] = 'Created BibTeX record.'
    if params[:create_roles]
      if @source.create_related_people_and_roles
        flash[:notice] << "Successfully created added #{@source.roles.count} people as authors/editors."
      else
        flash[:notice] << 'Associated People records were not created.'
      end
    end
    redirect_to url_for(@source.metamorphosize)
  else
    flash[:notice] = "An error occurred while creating the source record. #{@source.errors.messages}"
    redirect_to new_verbatim_reference_task_path(request.parameters)
  end
end

#create_verbatimObject



17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/tasks/bibliography/verbatim_reference_controller.rb', line 17

def create_verbatim
  @source = Source.new(source_params)
  if @source.save
    flash[:notice] = 'Created source as verbatim.'
    redirect_to url_for(@source.metamorphosize)
  else
    flash[:notice] = "Failed to create verbatim source. #{@source.errors.full_messages}."
    render :new
  end
end

#newObject

GET build_source_from_crossref_task_path



5
6
# File 'app/controllers/tasks/bibliography/verbatim_reference_controller.rb', line 5

def new
end

#previewObject



8
9
10
11
12
13
14
15
# File 'app/controllers/tasks/bibliography/verbatim_reference_controller.rb', line 8

def preview
  if citation_param.blank?
    flash[:notice] = 'Provide a citation.'
    render :new and return
  else
    @source = TaxonWorks::Vendor::Serrano.new_from_citation(citation: citation_param)
  end
end

#source_paramsObject (protected)



58
59
60
61
62
63
64
65
66
# File 'app/controllers/tasks/bibliography/verbatim_reference_controller.rb', line 58

def source_params
  params['source'][:project_sources_attributes] = [{project_id: sessions_current_project_id.to_s}]

  params.require(:source).permit(
    :verbatim,
    :type,
    project_sources_attributes: [:project_id]
  )
end