Class: TaxonDeterminationsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- TaxonDeterminationsController
- Defined in:
- app/controllers/taxon_determinations_controller.rb
Constant Summary
Constants included from ProjectsHelper
ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION
Instance Method Summary collapse
- #autocomplete ⇒ Object
-
#batch_create ⇒ Object
POST /taxon_determinations/batch_create.
-
#create ⇒ Object
POST /taxon_determinations POST /taxon_determinations.json.
-
#destroy ⇒ Object
DELETE /taxon_determinations/1 DELETE /taxon_determinations/1.json.
-
#download ⇒ Object
GET /taxon_determinations/download.
-
#edit ⇒ Object
GET /taxon_determinations/1/edit.
-
#index ⇒ Object
GET /taxon_determinations GET /taxon_determinations.json.
- #list ⇒ Object
-
#new ⇒ Object
GET /taxon_determinations/new.
-
#reorder ⇒ Object
PATCH /taxon_determinations/reorder?id[]=1.
-
#search ⇒ Object
GET /taxon_determinations/search.
- #set_taxon_determination ⇒ Object private
-
#show ⇒ Object
GET /taxon_determinations/1 GET /taxon_determinations/1.json.
- #taxon_determination_params ⇒ Object private
-
#update ⇒ Object
PATCH/PUT /taxon_determinations/1 PATCH/PUT /taxon_determinations/1.json.
Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration
Methods included from RedirectHelper
Methods included from RequestType
Methods included from LogRecent
Methods included from Cookies
#digest_cookie, #digested_cookie_exists?
Methods included from Whitelist
Methods included from ProjectsHelper
#cumulative_gb_per_year, #document_cumulative_gb_per_year, #document_gb_per_year, #gb_per_year, #image_cumulative_gb_per_year, #image_gb_per_year, #invalid_object, #project_classification, #project_link, #project_matches, #project_tag, #projects_list, #projects_search_form, #taxonworks_classification, #week_in_review_graphs
Methods included from Api::Intercept
Methods included from TokenAuthentication
#intercept_project, #intercept_user, #intercept_user_or_project, #project_token_authenticate, #token_authenticate
Instance Method Details
#autocomplete ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'app/controllers/taxon_determinations_controller.rb', line 97 def autocomplete @taxon_determinations = TaxonDetermination.find_for_autocomplete(params) .where(project_id: sessions_current_project_id) .limit(40) .distinct data = @taxon_determinations.collect do |t| {id: t.id, label: helpers.taxon_determination_tag(t), response_values: { params[:method] => t.id }, label_html: helpers.taxon_determination_tag(t) } end render json: data end |
#batch_create ⇒ Object
POST /taxon_determinations/batch_create
123 124 125 126 127 128 129 130 131 |
# File 'app/controllers/taxon_determinations_controller.rb', line 123 def batch_create render json: TaxonDetermination.batch_create( params[:collection_object_id], taxon_determination_params.to_h.merge( project_id: sessions_current_project_id, by: sessions_current_user_id ) ) end |
#create ⇒ Object
POST /taxon_determinations POST /taxon_determinations.json
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/controllers/taxon_determinations_controller.rb', line 42 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 |
#destroy ⇒ Object
DELETE /taxon_determinations/1 DELETE /taxon_determinations/1.json
72 73 74 75 76 77 78 |
# File 'app/controllers/taxon_determinations_controller.rb', line 72 def destroy @taxon_determination.destroy respond_to do |format| format.html { redirect_to taxon_determinations_url } format.json { head :no_content } end end |
#download ⇒ Object
GET /taxon_determinations/download
116 117 118 119 120 |
# File 'app/controllers/taxon_determinations_controller.rb', line 116 def download send_data Export::CSV.generate_csv(TaxonDetermination.where(project_id: sessions_current_project_id)), type: 'text', filename: "taxon_determinations_#{DateTime.now}.tsv" end |
#edit ⇒ Object
GET /taxon_determinations/1/edit
37 38 |
# File 'app/controllers/taxon_determinations_controller.rb', line 37 def edit end |
#index ⇒ Object
GET /taxon_determinations GET /taxon_determinations.json
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/taxon_determinations_controller.rb', line 8 def index respond_to do |format| format.html { @recent_objects = TaxonDetermination.recent_from_project_id(sessions_current_project_id).order(updated_at: :desc).limit(10) render '/shared/data/all/index' } format.json { @taxon_determinations = Queries::TaxonDetermination::Filter.new(params).all .page(params[:page]) .per(params[:per]) } end end |
#list ⇒ Object
22 23 24 |
# File 'app/controllers/taxon_determinations_controller.rb', line 22 def list @taxon_determinations = TaxonDetermination.with_project_id(sessions_current_project_id).order(:id).page(params[:page]) #.per(10) #.per(3) end |
#new ⇒ Object
GET /taxon_determinations/new
32 33 34 |
# File 'app/controllers/taxon_determinations_controller.rb', line 32 def new @taxon_determination = TaxonDetermination.new end |
#reorder ⇒ Object
PATCH /taxon_determinations/reorder?id[]=1
81 82 83 84 85 86 |
# File 'app/controllers/taxon_determinations_controller.rb', line 81 def reorder params[:id].reverse.each do |taxon_determination_id| TaxonDetermination.find(taxon_determination_id).move_to_top end render json: true end |
#search ⇒ Object
GET /taxon_determinations/search
89 90 91 92 93 94 95 |
# File 'app/controllers/taxon_determinations_controller.rb', line 89 def search if params[:id].blank? redirect_to taxon_determination_path, alert: '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 |
#set_taxon_determination ⇒ Object (private)
134 135 136 137 |
# File 'app/controllers/taxon_determinations_controller.rb', line 134 def set_taxon_determination @taxon_determination = TaxonDetermination.with_project_id(sessions_current_project_id).find(params[:id]) @recent_object = @taxon_determination end |
#show ⇒ Object
GET /taxon_determinations/1 GET /taxon_determinations/1.json
28 29 |
# File 'app/controllers/taxon_determinations_controller.rb', line 28 def show end |
#taxon_determination_params ⇒ Object (private)
139 140 141 142 143 144 145 146 |
# File 'app/controllers/taxon_determinations_controller.rb', line 139 def taxon_determination_params params.require(:taxon_determination).permit( :taxon_determination_object_id, :taxon_determination_object_type, :otu_id, :year_made, :month_made, :day_made, :position, roles_attributes: [:id, :_destroy, :type, :organization_id, :person_id, :position, person_attributes: [:last_name, :first_name, :suffix, :prefix]], otu_attributes: [:id, :_destroy, :name, :taxon_name_id] ) end |
#update ⇒ Object
PATCH/PUT /taxon_determinations/1 PATCH/PUT /taxon_determinations/1.json
58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/controllers/taxon_determinations_controller.rb', line 58 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 { render action: 'show', status: :created, location: @taxon_determination } else format.html { render action: 'edit' } format.json { render json: @taxon_determination.errors, status: :unprocessable_entity } end end end |