Class: CommonNamesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- CommonNamesController
- Defined in:
- app/controllers/common_names_controller.rb
Constant Summary
Constants included from ProjectsHelper
ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION
Instance Method Summary collapse
-
#api_index ⇒ Object
GET /api/v1/common_names.csv GET /api/v1/common_names.
-
#api_show ⇒ Object
GET /api/v1/common_names/:id.
- #common_name_params ⇒ Object private
-
#create ⇒ Object
POST /common_names POST /common_names.json.
-
#destroy ⇒ Object
DELETE /common_names/1 DELETE /common_names/1.json.
-
#edit ⇒ Object
GET /common_names/1/edit.
-
#index ⇒ Object
GET /common_names GET /common_names.json.
- #list ⇒ Object
-
#new ⇒ Object
GET /common_names/new.
- #set_common_name ⇒ Object private
-
#show ⇒ Object
GET /common_names/1 GET /common_names/1.json.
-
#update ⇒ Object
PATCH/PUT /common_names/1 PATCH/PUT /common_names/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/common_names.csv GET /api/v1/common_names
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'app/controllers/common_names_controller.rb', line 83 def api_index q = ::Queries::CommonName::Filter.new(params.merge!(api: true)).all .where(project_id: sessions_current_project_id) .order('common_names.id') if helpers.extend_response_with('citations') q = q.includes(citations: [:source, :topics, { citation_topics: :topic }]) end q = q.page(params[:page]).per(params[:per]) respond_to do |format| format.json { @common_names = q render '/common_names/api/v1/index' } format.csv { @common_names = q send_data Export::CSV.generate_csv( @common_names, exclude_columns: %w{updated_by_id created_by_id project_id}, ), type: 'text', filename: "common_names_#{DateTime.now}.tsv" } end end |
#api_show ⇒ Object
GET /api/v1/common_names/:id
110 111 112 |
# File 'app/controllers/common_names_controller.rb', line 110 def api_show render '/common_names/api/v1/show' end |
#common_name_params ⇒ Object (private)
120 121 122 |
# File 'app/controllers/common_names_controller.rb', line 120 def common_name_params params.require(:common_name).permit(:name, :geographic_area_id, :otu_id, :language_id, :start_year, :end_year) end |
#create ⇒ Object
POST /common_names POST /common_names.json
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/common_names_controller.rb', line 43 def create @common_name = CommonName.new(common_name_params) respond_to do |format| if @common_name.save format.html { redirect_to @common_name, notice: 'Common name was successfully created.' } format.json { render :show, status: :created, location: @common_name } else format.html { render :new } format.json { render json: @common_name.errors, status: :unprocessable_content } end end end |
#destroy ⇒ Object
DELETE /common_names/1 DELETE /common_names/1.json
73 74 75 76 77 78 79 |
# File 'app/controllers/common_names_controller.rb', line 73 def destroy @common_name.destroy respond_to do |format| format.html { redirect_to common_names_url, notice: 'Common name was successfully destroyed.' } format.json { head :no_content } end end |
#edit ⇒ Object
GET /common_names/1/edit
34 35 |
# File 'app/controllers/common_names_controller.rb', line 34 def edit end |
#index ⇒ Object
GET /common_names GET /common_names.json
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/common_names_controller.rb', line 9 def index respond_to do |format| format.html do @recent_objects = CommonName.recent_from_project_id(sessions_current_project_id).order(updated_at: :desc).limit(10) render '/shared/data/all/index' end format.json { @common_names = Queries::CommonName::Filter.new(params).all .page(params[:page]) .per(params[:per]) } end end |
#list ⇒ Object
37 38 39 |
# File 'app/controllers/common_names_controller.rb', line 37 def list @common_names = CommonName.with_project_id(sessions_current_project_id).page(params[:page]) #.per(10) end |
#new ⇒ Object
GET /common_names/new
29 30 31 |
# File 'app/controllers/common_names_controller.rb', line 29 def new @common_name = CommonName.new end |
#set_common_name ⇒ Object (private)
116 117 118 |
# File 'app/controllers/common_names_controller.rb', line 116 def set_common_name @common_name = CommonName.with_project_id(sessions_current_project_id).find(params[:id]) end |
#show ⇒ Object
GET /common_names/1 GET /common_names/1.json
25 26 |
# File 'app/controllers/common_names_controller.rb', line 25 def show end |
#update ⇒ Object
PATCH/PUT /common_names/1 PATCH/PUT /common_names/1.json
59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/controllers/common_names_controller.rb', line 59 def update respond_to do |format| if @common_name.update(common_name_params) format.html { redirect_to @common_name, notice: 'Common name was successfully updated.' } format.json { render :show, status: :ok, location: @common_name } else format.html { render :edit } format.json { render json: @common_name.errors, status: :unprocessable_content } end end end |