Class: Tasks::Accessions::Breakdown::SqedDepictionController

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

Instance Method Summary collapse

Methods included from TaskControllerConfiguration

#set_is_task_controller

Instance Method Details

#collection_object_paramsObject (protected)


48
49
50
51
52
53
54
55
56
# File 'app/controllers/tasks/accessions/breakdown/sqed_depiction_controller.rb', line 48

def collection_object_params
  params.require(:collection_object).permit(
    :buffered_collecting_event, :buffered_other_labels, :buffered_determinations, :total,
    identifiers_attributes: [:id, :namespace_id, :identifier, :type, :_destroy],
    tags_attributes: [:id, :keyword_id, :_destroy],
    taxon_determinations_attributes: [:id, :otu_id, :_destroy],
    notes_attributes: [:id, :text, :_destroy]
  )
end

#indexObject

GET /tasks/accession/breakdown/depiction/:id # id is a collection_object_id


13
14
15
16
17
18
19
20
# File 'app/controllers/tasks/accessions/breakdown/sqed_depiction_controller.rb', line 13

def index
  @result = SqedToTaxonworks::Result.new(
    depiction_id: @sqed_depiction.depiction.id,
    namespace_id: params[:namespace_id]
  )

  @identifier_prototype = Identifier.prototype_identifier(sessions_current_project_id, sessions_current_user_id)
end

#set_sqed_depictionObject (protected)


58
59
60
61
62
63
# File 'app/controllers/tasks/accessions/breakdown/sqed_depiction_controller.rb', line 58

def set_sqed_depiction
  @sqed_depiction = SqedDepiction.where(project_id: sessions_current_project_id).find(params[:id])
  @sqed_depiction.update_column(:in_progress, Time.now)
  # TODO: Run jobs in background with admin task.
  # @sqed_depiction.preprocess
end

#todo_mapObject

/tasks/accessions/breakdown/sqed_depiction/todo_map


7
8
9
10
# File 'app/controllers/tasks/accessions/breakdown/sqed_depiction_controller.rb', line 7

def todo_map
  SqedDepiction.clear_stale_progress
  @sqed_depictions = SqedDepiction.where(project_id: sessions_current_project_id).order(:id).page(params[:page]).per(100)
end

#updateObject


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/tasks/accessions/breakdown/sqed_depiction_controller.rb', line 22

def update
  next_sqed_depiction = @sqed_depiction

  if @sqed_depiction.depiction.depiction_object.update(collection_object_params)
    flash[:notice] = 'Successfully updated'

    next_sqed_depiction =
      case params[:commit]
      when 'Save and next w/out data [n]'
        @sqed_depiction.next_without_data(true) # true handles stale settings
      when 'Save and next'
        @sqed_depiction.nearby_sqed_depictions(0, 1, true)[:after].first # true handles stale settings
      else
        @sqed_depiction
      end
  else
    flash[:alert] = 'Failed to update! ' + @sqed_depiction.depiction.depiction_object.errors.full_messages.join('; ').html_safe
  end

  namespace_id = (params[:lock_namespace] ? params[:collection_object][:identifiers_attributes]['0'][:namespace_id] : nil)

  redirect_to sqed_depiction_breakdown_task_path(next_sqed_depiction, namespace_id)
end