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

- (Object) citation_param (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

- (Object) create_bibtex



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 = Source.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 @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

- (Object) create_verbatim



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 @source.metamorphosize
  else
    flash[:notice] = "Failed to create verbatim source. #{@source.errors.full_messages}."
    render :new 
  end
end

- (Object) new

GET build_source_from_crossref_task_path



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

def new
end

- (Object) preview



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 = Source.new_from_citation(citation: citation_param)
  end
end

- (Object) source_params (protected)



58
59
60
61
62
63
64
# 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