Class: TaxonDeterminationsController

Inherits:
ApplicationController show all
Includes:
DataControllerConfiguration::ProjectDataControllerConfiguration
Defined in:
app/controllers/taxon_determinations_controller.rb

Instance Attribute Summary

Attributes inherited from ApplicationController

#is_data_controller, #is_task_controller, #meta_data, #meta_description, #meta_keywords, #meta_title, #page_title, #site_name

Instance Method Summary (collapse)

Methods inherited from ApplicationController

#clear_project_and_user_variables, #digest_cookie, #digested_cookie_exists?, #disable_turbolinks, #intercept_api, #invalid_object, #is_data_controller?, #is_task_controller?, #log_user_recent_route, #notice_user, #project_matches, #record_not_found, #set_project_and_user_variables, #set_project_from_params, #token_authenticate

Methods included from ProjectsHelper

#project_link, #project_tag, #projects_list, #projects_search_form

Instance Method Details

- (Object) autocomplete



80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'app/controllers/taxon_determinations_controller.rb', line 80

def autocomplete
  @taxon_determinations = taxon_determination.find_for_autocomplete(params.merge(project_id: sessions_current_project_id))
  data = @taxon_determinations.collect do |t|
    {id: t.id,
     label: TaxonDeterminationsHelper.taxon_determination_tag(t),
     response_values: {
         params[:method] => t.id
     },
     label_html: TaxonDeterminationsHelper.taxon_determination_tag(t) #  render_to_string(:partial => 'shared/autocomplete/taxon_name.html', :object => t)
    }
  end

  render :json => data
end

- (Object) create

POST /taxon_determinations POST /taxon_determinations.json



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/taxon_determinations_controller.rb', line 33

def create
  @taxon_determination = TaxonDetermination.new(taxon_determination_params)

  respond_to do |format|
    if @taxon_determination.save
      format.html { redirect_to @taxon_determination, notice: 'Taxon determination was successfully created.' }
      format.json { render action: 'show', status: :created, location: @taxon_determination }
    else
      format.html { render action: 'new' }
      format.json { render json: @taxon_determination.errors, status: :unprocessable_entity }
    end
  end
end

- (Object) destroy

DELETE /taxon_determinations/1 DELETE /taxon_determinations/1.json



63
64
65
66
67
68
69
# File 'app/controllers/taxon_determinations_controller.rb', line 63

def destroy
  @taxon_determination.destroy
  respond_to do |format|
    format.html { redirect_to taxon_determinations_url }
    format.json { head :no_content }
  end
end

- (Object) download

GET /taxon_determinations/download



96
97
98
# File 'app/controllers/taxon_determinations_controller.rb', line 96

def download
  send_data TaxonDetermination.generate_download( TaxonDetermination.where(project_id: $project_id) ), type: 'text', filename: "taxon_determinations_#{DateTime.now.to_s}.csv"
end

- (Object) edit

GET /taxon_determinations/1/edit



28
29
# File 'app/controllers/taxon_determinations_controller.rb', line 28

def edit
end

- (Object) index

GET /taxon_determinations GET /taxon_determinations.json



8
9
10
11
# File 'app/controllers/taxon_determinations_controller.rb', line 8

def index
  @recent_objects = TaxonDetermination.recent_from_project_id($project_id).order(updated_at: :desc).limit(10)
  render '/shared/data/all/index'
end

- (Object) list



13
14
15
# File 'app/controllers/taxon_determinations_controller.rb', line 13

def list
  @taxon_determinations = TaxonDetermination.with_project_id($project_id).order(:id).page(params[:page]) #.per(10) #.per(3)
end

- (Object) new

GET /taxon_determinations/new



23
24
25
# File 'app/controllers/taxon_determinations_controller.rb', line 23

def new
  @taxon_determination = TaxonDetermination.new
end

- (Object) search

GET /taxon_determinations/search



72
73
74
75
76
77
78
# File 'app/controllers/taxon_determinations_controller.rb', line 72

def search
  if params[:id].blank?
    redirect_to taxon_determination_path, notice: 'You must select an item from the list with a click or tab press before clicking show.'
  else
    redirect_to taxon_determination_path(params[:id])
  end
end

- (Object) set_taxon_determination (private)



101
102
103
104
# File 'app/controllers/taxon_determinations_controller.rb', line 101

def set_taxon_determination
  @taxon_determination = TaxonDetermination.with_project_id($project_id).find(params[:id])
  @recent_object = @taxon_determination 
end

- (Object) show

GET /taxon_determinations/1 GET /taxon_determinations/1.json



19
20
# File 'app/controllers/taxon_determinations_controller.rb', line 19

def show
end

- (Object) taxon_determination_params (private)



106
107
108
109
110
111
112
# File 'app/controllers/taxon_determinations_controller.rb', line 106

def taxon_determination_params
  params.require(:taxon_determination).permit(
    :biological_collection_object_id, :otu_id, :year_made, :month_made, :day_made,
    roles_attributes: [:id, :_destroy, :type, :person_id, :position, person_attributes: [:last_name, :first_name, :suffix, :prefix]],
    otu_attributes: [:id, :_destroy, :name, :taxon_name_id]
  )
end

- (Object) update

PATCH/PUT /taxon_determinations/1 PATCH/PUT /taxon_determinations/1.json



49
50
51
52
53
54
55
56
57
58
59
# File 'app/controllers/taxon_determinations_controller.rb', line 49

def update
  respond_to do |format|
    if @taxon_determination.update(taxon_determination_params)
      format.html { redirect_to @taxon_determination, notice: 'Taxon determination was successfully updated.' }
      format.json { head :no_content }
    else
      format.html { render action: 'edit' }
      format.json { render json: @taxon_determination.errors, status: :unprocessable_entity }
    end
  end
end