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

- (Object) create

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

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

- (Object) material_params (protected)



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

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

- (Object) new

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

- (Object) set_fixed_variables (protected)



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

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

- (Object) set_variable_variables(material) (protected)



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

def set_variable_variables(material)
  @locks = material.locks

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