Class: Tasks::Accessions::Quick::VerbatimMaterialController

Inherits:
ApplicationController
  • Object
show all
Includes:
TaskControllerConfiguration
Defined in:
app/controllers/tasks/accessions/quick/verbatim_material_controller.rb

Instance Method Summary collapse

Methods included from TaskControllerConfiguration

#set_is_task_controller

Instance Method Details

#createObject

POST tasks_accessions_quick_verbatim_material_create_path



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/tasks/accessions/quick/verbatim_material_controller.rb', line 13

def create
  @material = Material.create_quick_verbatim(material_params)

  saved, errors = @material.save

  if saved
    flash[:notice] = 'Added records.'
    @material = @material.duplicate_with_locks
  else
    flash[:notice] =  "Failed to add records #{errors.messages}"
  end

  set_variable_variables(@material)
  render :new
end

#get_recentObject (protected)



31
32
33
# File 'app/controllers/tasks/accessions/quick/verbatim_material_controller.rb', line 31

def get_recent
  @recent = CollectionObject.created_last(5).where(created_by_id: sessions_current_user_id, project_id: sessions_current_project_id)
end

#material_paramsObject (protected)



52
53
54
55
56
# File 'app/controllers/tasks/accessions/quick/verbatim_material_controller.rb', line 52

def material_params
  # params.permit(:collection_object, :identifier, :repository, :locks, :note, :collection_objects, :commit).to_unsafe_h
  #TODO this is a security problem needing resolution @mjy
  params.to_unsafe_h
end

#newObject

GET quick_verbatim_material_task



6
7
8
9
10
# File 'app/controllers/tasks/accessions/quick/verbatim_material_controller.rb', line 6

def new
  @material = Material::QuickVerbatimResponse.new(material_params)
  @related_routes = UserTasks.related_routes('quick_verbatim_material_task')
  set_variable_variables(@material)
end

#set_fixed_variablesObject (protected)



35
36
37
38
39
# File 'app/controllers/tasks/accessions/quick/verbatim_material_controller.rb', line 35

def set_fixed_variables
  # @repositories       = Repository.order(:name).all
  # @namespaces         = Namespace.order(:name).all
  @biocuration_groups = BiocurationGroup.with_project_id(sessions_current_project_id)
end

#set_variable_variables(material) ⇒ Object (protected)



41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/tasks/accessions/quick/verbatim_material_controller.rb', line 41

def set_variable_variables(material)
  @locks = material.locks

  @collection_object = material.collection_object
  @identifier = material.identifier
  @namespace = material.namespace
  @repository = material.repository
  @preparation_type = material.preparation_type
  @note = material.note
end