Class: TaxonNameClassificationsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- TaxonNameClassificationsController
- Includes:
- DataControllerConfiguration::BatchByFilterScope, DataControllerConfiguration::ProjectDataControllerConfiguration
- Defined in:
- app/controllers/taxon_name_classifications_controller.rb
Constant Summary
Constants included from ProjectsHelper
ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION
Instance Method Summary collapse
-
#api_index ⇒ Object
GET /api/v1/taxon_name_classifications.
-
#api_show ⇒ Object
GET /api/v1/taxon_name_classifications//:id.
- #autocomplete ⇒ Object
- #batch_by_filter_scope_params ⇒ Object private
-
#create ⇒ Object
POST /taxon_name_classifications POST /taxon_name_classifications.json.
-
#destroy ⇒ Object
DELETE /taxon_name_classifications/1 DELETE /taxon_name_classifications/1.json.
-
#download ⇒ Object
GET /taxon_name_classifications/download.
- #edit ⇒ Object
-
#index ⇒ Object
GET /taxon_name_classifications GET /taxon_name_classifications.json.
- #list ⇒ Object
- #new ⇒ Object
-
#search ⇒ Object
GET /taxon_name_classifications/search.
- #set_taxon_name_classification ⇒ Object private
-
#show ⇒ Object
GET /taxon_name_classifications/id.json.
- #taxon_name_classification_params ⇒ Object private
- #taxon_name_classification_types ⇒ Object
-
#update ⇒ Object
PATCH/PUT /taxon_name_classifications/1 PATCH/PUT /taxon_name_classifications/1.json.
Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration
Methods inherited from ApplicationController
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_initials, #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_name_classifications
150 151 152 153 154 155 156 157 |
# File 'app/controllers/taxon_name_classifications_controller.rb', line 150 def api_index @taxon_name_classifications = Queries::TaxonNameClassification::Filter.new(params.merge!(api: true)).all .where(project_id: sessions_current_project_id) .order('taxon_name_classifications.id') .page(params[:page]) .per(params[:per]) render '/taxon_name_classifications/api/v1/index' end |
#api_show ⇒ Object
GET /api/v1/taxon_name_classifications//:id
160 161 162 |
# File 'app/controllers/taxon_name_classifications_controller.rb', line 160 def api_show render '/taxon_name_classifications/api/v1/show' end |
#autocomplete ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'app/controllers/taxon_name_classifications_controller.rb', line 122 def autocomplete # TODO: make reasonable, if used @taxon_name_classifications = TaxonNameClassification.where(id: params[:term]).with_project_id(params[:project_id]) data = @taxon_name_classifications.collect do |t| { id: t.id, label: TaxonNameClassificationsHelper.taxon_name_classification_tag(t), response_values: { params[:method] => t.id, }, label_html: TaxonNameClassificationsHelper.taxon_name_classification_tag(t) # render_to_string(:partial => 'shared/autocomplete/taxon_name.html', :object => t) } end render json: data end |
#batch_by_filter_scope_params ⇒ Object (private)
177 178 179 180 |
# File 'app/controllers/taxon_name_classifications_controller.rb', line 177 def batch_by_filter_scope_params # Current batching only uses mode, not params. ActionController::Parameters.new.permit() end |
#create ⇒ Object
POST /taxon_name_classifications POST /taxon_name_classifications.json
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/controllers/taxon_name_classifications_controller.rb', line 36 def create @taxon_name_classification = TaxonNameClassification.new(taxon_name_classification_params) respond_to do |format| if @taxon_name_classification.save format.html { redirect_to url_for(@taxon_name_classification.taxon_name.), notice: 'Taxon name classification was successfully created.' } format.json { render :show, status: :created, location: @taxon_name_classification. } else format.html { redirect_back(fallback_location: (request.referer || root_path), notice: 'Taxon name classification was NOT successfully created.') } format.json { render json: @taxon_name_classification.errors, status: :unprocessable_content } end end end |
#destroy ⇒ Object
DELETE /taxon_name_classifications/1 DELETE /taxon_name_classifications/1.json
93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'app/controllers/taxon_name_classifications_controller.rb', line 93 def destroy @taxon_name_classification.destroy respond_to do |format| if @taxon_name_classification.destroyed? format.html { destroy_redirect @taxon_name_classification, notice: 'Taxon name classification was successfully destroyed.' } format.json { head :no_content } else format.html { destroy_redirect @taxon_name_classification, notice: 'Taxon name classification was not destroyed, ' + @taxon_name_classification.errors..join('; ') } format.json { render json: @taxon_name_classification.errors, status: :unprocessable_content } end end end |
#download ⇒ Object
GET /taxon_name_classifications/download
140 141 142 143 |
# File 'app/controllers/taxon_name_classifications_controller.rb', line 140 def download send_data Export::CSV.generate_csv(TaxonNameClassification.where(project_id: sessions_current_project_id)), type: 'text', filename: "taxon_name_classifications_#{DateTime.now}.tsv" end |
#edit ⇒ Object
30 31 32 |
# File 'app/controllers/taxon_name_classifications_controller.rb', line 30 def edit redirect_to new_taxon_name_task_path(taxon_name_id: @taxon_name_classification.taxon_name) end |
#index ⇒ Object
GET /taxon_name_classifications GET /taxon_name_classifications.json
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/taxon_name_classifications_controller.rb', line 10 def index respond_to do |format| format.html do @recent_objects = TaxonNameClassification.recent_from_project_id(sessions_current_project_id) .order(updated_at: :desc).limit(10) render '/shared/data/all/index' end format.json { @taxon_name_classifications = Queries::TaxonNameClassification::Filter.new(params) .all .page(params[:page]) .per(params[:per]) } end end |
#list ⇒ Object
106 107 108 109 |
# File 'app/controllers/taxon_name_classifications_controller.rb', line 106 def list @taxon_name_classifications = TaxonNameClassification.with_project_id(sessions_current_project_id) .order(:id).page(params[:page]) end |
#new ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'app/controllers/taxon_name_classifications_controller.rb', line 77 def new taxon_name_id = params[:taxon_name_classification].try(:[], :taxon_name_id) taxon_name = TaxonName.where( id: taxon_name_id, project_id: sessions_current_project_id, ).first if taxon_name redirect_to new_taxon_name_task_path(taxon_name_id: taxon_name.id) else redirect_to new_taxon_name_task_path, notice: 'Create TaxonNameClassifications in the context of a TaxonName.' end end |
#search ⇒ Object
GET /taxon_name_classifications/search
112 113 114 115 116 117 118 119 120 |
# File 'app/controllers/taxon_name_classifications_controller.rb', line 112 def search if params[:id].blank? redirect_to taxon_name_classification_path, notice: 'You must select an item from the list with a click or ' \ 'tab press before clicking show.' else redirect_to taxon_name_classification_path(params[:id]) end end |
#set_taxon_name_classification ⇒ Object (private)
166 167 168 |
# File 'app/controllers/taxon_name_classifications_controller.rb', line 166 def set_taxon_name_classification @taxon_name_classification = TaxonNameClassification.with_project_id(sessions_current_project_id).find(params[:id]) end |
#show ⇒ Object
GET /taxon_name_classifications/id.json
27 28 |
# File 'app/controllers/taxon_name_classifications_controller.rb', line 27 def show end |
#taxon_name_classification_params ⇒ Object (private)
170 171 172 173 174 175 |
# File 'app/controllers/taxon_name_classifications_controller.rb', line 170 def taxon_name_classification_params params.require(:taxon_name_classification).permit( :taxon_name_id, :type, origin_citation_attributes: [:id, :_destroy, :source_id, :pages], ) end |
#taxon_name_classification_types ⇒ Object
145 146 147 |
# File 'app/controllers/taxon_name_classifications_controller.rb', line 145 def taxon_name_classification_types render json: TAXON_NAME_CLASSIFICATION_JSON end |
#update ⇒ Object
PATCH/PUT /taxon_name_classifications/1 PATCH/PUT /taxon_name_classifications/1.json
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/controllers/taxon_name_classifications_controller.rb', line 58 def update respond_to do |format| if @taxon_name_classification.update(taxon_name_classification_params) @taxon_name_classification = TaxonNameClassification.find(@taxon_name_classification.id) format.html { redirect_back(fallback_location: (request.referer || root_path), notice: 'Taxon name classification was successfully updated.') } format.json { render :show, status: :ok, location: @taxon_name_classification. } else format.html { redirect_back(fallback_location: (request.referer || root_path), notice: 'Taxon name classification was NOT successfully updated.') } format.json { render json: @taxon_name_classification.errors, status: :unprocessable_content } end end end |