Class: Tasks::Accessions::Report::DwcController

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

Instance Method Summary (collapse)

Methods included from TaskControllerConfiguration

#set_is_task_controller

Instance Method Details

- (Object) download



22
23
24
25
26
27
28
29
30
# File 'app/controllers/tasks/accessions/report/dwc_controller.rb', line 22

def download
  # If failing remove begin/ensure/end to report Raised errors
  begin
    data = Dwca::Packer::Data.new(DwcOccurrence.where(project_id: sessions_current_project_id))
    send_data(data.getzip, type: 'application/zip', filename: data.filename)
  ensure
    data.cleanup
  end
end

- (Object) index

tasks/accessions/report/dwc



5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/tasks/accessions/report/dwc_controller.rb', line 5

def index 
  respond_to do |format|
    format.html do
      @collection_objects = CollectionObject.order(:id).includes(:dwc_occurrence).with_project_id(sessions_current_project_id).page(params[:page]).per(params[:per] || 30)
    end
    format.json {
      # TEMPORARY HACK! To be resolved with proper filter params at some points
      # Currently only used in digitize recent modal
      @collection_objects = CollectionObject.where(project_id: sessions_current_project_id).order(updated_at: :desc).includes(:dwc_occurrence).page(params[:page]).per(params[:per] || 30)
    }
  end
end

- (Object) row



18
19
20
# File 'app/controllers/tasks/accessions/report/dwc_controller.rb', line 18

def row
  @dwc_occurrence = CollectionObject.includes(:dwc_occurrence).find(params[:id]).get_dwc_occurrence # find or compute for
end