Class: TaxonNameRelationshipsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- TaxonNameRelationshipsController
- Defined in:
- app/controllers/taxon_name_relationships_controller.rb
Instance Method Summary collapse
-
#api_index ⇒ Object
GET /api/v1/taxon_name_relationships.
- #api_params ⇒ Object private
-
#api_show ⇒ Object
GET /api/v1/taxon_name_relationships/:id.
-
#create ⇒ Object
POST /taxon_name_relationships POST /taxon_name_relationships.json.
-
#destroy ⇒ Object
DELETE /taxon_name_relationships/1 DELETE /taxon_name_relationships/1.json.
-
#download ⇒ Object
GET /taxon_name_relationships/download.
-
#edit ⇒ Object
GET /taxon_name_relationships/1/edit.
- #filter_params ⇒ Object private
-
#index ⇒ Object
GET /taxon_name_relationships GET /taxon_name_relationships.json.
- #list ⇒ Object
-
#new ⇒ Object
GET /taxon_name_relationships/new.
-
#search ⇒ Object
GET /taxon_name_relationships/search.
- #set_taxon_name_relationship ⇒ Object private
-
#show ⇒ Object
GET /taxon_name_relationships/1 GET /taxon_name_relationships/1.json.
- #taxon_name_relationship_params ⇒ Object private
-
#taxon_name_relationship_types ⇒ Object
GET /api/v1//taxon_name_relationships/taxon_name_relationship_types GET /taxon_name_relationships/taxon_name_relationship_types.
-
#type_relationships ⇒ Object
GET /taxon_name_relationships/type_relationships.
-
#update ⇒ Object
PATCH/PUT /taxon_name_relationships/1 PATCH/PUT /taxon_name_relationships/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
#invalid_object, #project_link, #project_matches, #project_tag, #projects_list, #projects_search_form
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_relationships
118 119 120 121 122 123 124 125 |
# File 'app/controllers/taxon_name_relationships_controller.rb', line 118 def api_index @taxon_name_relationships = Queries::TaxonNameRelationship::Filter.new(api_params).all .where(project_id: sessions_current_project_id) .order('taxon_name_relationships.id') .page(params[:page]) .per(params[:per]) render '/taxon_name_relationships/api/v1/index' end |
#api_params ⇒ Object (private)
145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'app/controllers/taxon_name_relationships_controller.rb', line 145 def api_params params.permit( :object_taxon_name_id, :subject_taxon_name_id, :taxon_name_id, :taxon_name_relationship_set, :taxon_name_relationship_type, object_taxon_name_id: [], subject_taxon_name_id: [], taxon_name_id: [], taxon_name_relationship_set: [], taxon_name_relationship_type: [] ).to_h.symbolize_keys.merge(project_id: sessions_current_project_id) end |
#api_show ⇒ Object
GET /api/v1/taxon_name_relationships/:id
128 129 130 |
# File 'app/controllers/taxon_name_relationships_controller.rb', line 128 def api_show render '/taxon_name_relationships/api/v1/show' end |
#create ⇒ Object
POST /taxon_name_relationships POST /taxon_name_relationships.json
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/taxon_name_relationships_controller.rb', line 39 def create @taxon_name_relationship = TaxonNameRelationship.new(taxon_name_relationship_params) respond_to do |format| if @taxon_name_relationship.save format.html { redirect_to url_for(@taxon_name_relationship.), notice: 'Taxon name relationship was successfully created.' } format.json { render action: 'show', status: :created, location: @taxon_name_relationship. } else format.html { render action: 'new' } format.json { render json: @taxon_name_relationship.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /taxon_name_relationships/1 DELETE /taxon_name_relationships/1.json
72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'app/controllers/taxon_name_relationships_controller.rb', line 72 def destroy @taxon_name_relationship.destroy respond_to do |format| if @taxon_name_relationship.destroyed? format.html { destroy_redirect @taxon_name_relationship, notice: 'Taxon name relationship was successfully destroyed.' } format.json { head :no_content} else format.html { destroy_redirect @taxon_name_relationship, notice: 'Taxon name relationship was not destroyed, ' + @taxon_name_relationship.errors..join('; ') } format.json { render json: @taxon_name_relationship.errors, status: :unprocessable_entity } end end end |
#download ⇒ Object
GET /taxon_name_relationships/download
101 102 103 104 |
# File 'app/controllers/taxon_name_relationships_controller.rb', line 101 def download send_data Export::Download.generate_csv(TaxonNameRelationship.where(project_id: sessions_current_project_id)), type: 'text', filename: "taxon_name_relationships_#{DateTime.now}.csv" end |
#edit ⇒ Object
GET /taxon_name_relationships/1/edit
33 34 35 |
# File 'app/controllers/taxon_name_relationships_controller.rb', line 33 def edit @taxon_name_relationship.source = Source.new if !@taxon_name_relationship.source end |
#filter_params ⇒ Object (private)
160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'app/controllers/taxon_name_relationships_controller.rb', line 160 def filter_params params.permit( :object_taxon_name_id, :subject_taxon_name_id, :taxon_name_id, :taxon_name_relationship_set, :taxon_name_relationship_type, object_taxon_name_id: [], subject_taxon_name_id: [], taxon_name_id: [], taxon_name_relationship_set: [], taxon_name_relationship_type: [], ).to_h.symbolize_keys.merge(project_id: sessions_current_project_id) end |
#index ⇒ Object
GET /taxon_name_relationships GET /taxon_name_relationships.json
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/taxon_name_relationships_controller.rb', line 9 def index respond_to do |format| format.html do @recent_objects = TaxonNameRelationship.recent_from_project_id(sessions_current_project_id) .order(updated_at: :desc).limit(10) render '/shared/data/all/index' end format.json { @taxon_name_relationships = Queries::TaxonNameRelationship::Filter.new(filter_params).all.page(params[:page]).per(params[:per] || 500) } end end |
#list ⇒ Object
85 86 87 88 |
# File 'app/controllers/taxon_name_relationships_controller.rb', line 85 def list @taxon_name_relationships = TaxonNameRelationship.with_project_id(sessions_current_project_id) .order(:id).page(params[:page]) end |
#new ⇒ Object
GET /taxon_name_relationships/new
28 29 30 |
# File 'app/controllers/taxon_name_relationships_controller.rb', line 28 def new @taxon_name_relationship = TaxonNameRelationship.new end |
#search ⇒ Object
GET /taxon_name_relationships/search
91 92 93 94 95 96 97 98 |
# File 'app/controllers/taxon_name_relationships_controller.rb', line 91 def search if params[:id].blank? redirect_to taxon_name_relationship_path, alert: 'You must select an item from the list with a click or tab press before clicking show.' else redirect_to taxon_name_relationship_path(params[:id]) end end |
#set_taxon_name_relationship ⇒ Object (private)
134 135 136 |
# File 'app/controllers/taxon_name_relationships_controller.rb', line 134 def set_taxon_name_relationship @taxon_name_relationship = TaxonNameRelationship.with_project_id(sessions_current_project_id).find(params[:id]) end |
#show ⇒ Object
GET /taxon_name_relationships/1 GET /taxon_name_relationships/1.json
24 25 |
# File 'app/controllers/taxon_name_relationships_controller.rb', line 24 def show end |
#taxon_name_relationship_params ⇒ Object (private)
138 139 140 141 142 143 |
# File 'app/controllers/taxon_name_relationships_controller.rb', line 138 def taxon_name_relationship_params params.require(:taxon_name_relationship).permit( :subject_taxon_name_id, :object_taxon_name_id, :type, origin_citation_attributes: [:id, :_destroy, :source_id, :pages] ) end |
#taxon_name_relationship_types ⇒ Object
GET /api/v1//taxon_name_relationships/taxon_name_relationship_types GET /taxon_name_relationships/taxon_name_relationship_types
113 114 115 |
# File 'app/controllers/taxon_name_relationships_controller.rb', line 113 def taxon_name_relationship_types render json: TAXON_NAME_RELATIONSHIPS_JSON end |
#type_relationships ⇒ Object
GET /taxon_name_relationships/type_relationships
107 108 109 |
# File 'app/controllers/taxon_name_relationships_controller.rb', line 107 def type_relationships render json: TAXON_NAME_RELATIONSHIPS_TYPE_JSON end |
#update ⇒ Object
PATCH/PUT /taxon_name_relationships/1 PATCH/PUT /taxon_name_relationships/1.json
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/controllers/taxon_name_relationships_controller.rb', line 56 def update respond_to do |format| if @taxon_name_relationship.update(taxon_name_relationship_params) @taxon_name_relationship = TaxonNameRelationship.find(@taxon_name_relationship.id) # reset class format.html { redirect_to url_for(@taxon_name_relationship.), notice: 'Taxon name relationship was successfully updated.' } format.json { render :show, status: :ok, location: @taxon_name_relationship. } else format.html { render action: 'edit' } format.json { render json: @taxon_name_relationship.errors, status: :unprocessable_entity } end end end |