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
- 
  
    
      #api_index  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    GET /api/v1/taxon_determinations. 
- 
  
    
      #api_show  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    GET /api/v1/taxon_determinations/:id. 
- #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, #cumulative_projects_created_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_login_link, #project_matches, #project_tag, #projects_list, #projects_search_form, #sound_cumulative_gb_per_year, #sound_gb_per_year, #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
#api_index ⇒ Object
GET /api/v1/taxon_determinations
| 24 25 26 27 28 29 30 31 32 33 34 35 | # File 'app/controllers/taxon_determinations_controller.rb', line 24 def api_index q = ::Queries::TaxonDetermination::Filter.new(params.merge!(api: true)).all .where(project_id: sessions_current_project_id) .order('taxon_determinations.id') respond_to do |format| format.json { @taxon_determinations = q.page(params[:page]).per(params[:per]) render '/taxon_determinations/api/v1/index' } end end | 
#api_show ⇒ Object
GET /api/v1/taxon_determinations/:id
| 38 39 40 | # File 'app/controllers/taxon_determinations_controller.rb', line 38 def api_show render '/taxon_determinations/api/v1/show' end | 
#autocomplete ⇒ Object
| 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | # File 'app/controllers/taxon_determinations_controller.rb', line 122 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
| 148 149 150 151 152 153 154 155 156 | # File 'app/controllers/taxon_determinations_controller.rb', line 148 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
| 62 63 64 65 66 67 68 69 70 71 72 73 74 | # File 'app/controllers/taxon_determinations_controller.rb', line 62 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
| 92 93 94 95 96 97 98 99 100 101 102 103 | # File 'app/controllers/taxon_determinations_controller.rb', line 92 def destroy @taxon_determination.destroy respond_to do |format| if @taxon_determination.destroyed? format.html { destroy_redirect @taxon_determination, notice: 'Taxon determination was successfully destroyed.' } format.json { head :no_content } else format.html { destroy_redirect @taxon_determination, notice: 'Taxon determination was not destroyed, ' + @taxon_determination.errors..join('; ') } format.json { render json: @taxon_determination.errors, status: :unprocessable_entity } end end end | 
#download ⇒ Object
GET /taxon_determinations/download
| 141 142 143 144 145 | # File 'app/controllers/taxon_determinations_controller.rb', line 141 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
| 57 58 | # File 'app/controllers/taxon_determinations_controller.rb', line 57 def edit end | 
#index ⇒ Object
GET /taxon_determinations GET /taxon_determinations.json
| 9 10 11 12 13 14 15 16 17 18 19 20 21 | # File 'app/controllers/taxon_determinations_controller.rb', line 9 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
| 42 43 44 | # File 'app/controllers/taxon_determinations_controller.rb', line 42 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
| 52 53 54 | # File 'app/controllers/taxon_determinations_controller.rb', line 52 def new @taxon_determination = TaxonDetermination.new end | 
#reorder ⇒ Object
PATCH /taxon_determinations/reorder?id[]=1
| 106 107 108 109 110 111 | # File 'app/controllers/taxon_determinations_controller.rb', line 106 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
| 114 115 116 117 118 119 120 | # File 'app/controllers/taxon_determinations_controller.rb', line 114 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)
| 159 160 161 162 | # File 'app/controllers/taxon_determinations_controller.rb', line 159 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
| 48 49 | # File 'app/controllers/taxon_determinations_controller.rb', line 48 def show end | 
#taxon_determination_params ⇒ Object (private)
| 164 165 166 167 168 169 170 171 | # File 'app/controllers/taxon_determinations_controller.rb', line 164 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
| 78 79 80 81 82 83 84 85 86 87 88 | # File 'app/controllers/taxon_determinations_controller.rb', line 78 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 |