Class: CollectionProfilesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- CollectionProfilesController
- Defined in:
- app/controllers/collection_profiles_controller.rb
Constant Summary
Constants included from ProjectsHelper
ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION
Instance Method Summary collapse
- #autocomplete ⇒ Object
-
#collection_profile_params ⇒ Object
private
Never trust parameters from the scary internet, only allow the white list through.
-
#create ⇒ Object
POST /collection_profiles POST /collection_profiles.json.
-
#destroy ⇒ Object
DELETE /collection_profiles/1 DELETE /collection_profiles/1.json.
-
#edit ⇒ Object
GET /collection_profiles/1/edit.
-
#index ⇒ Object
GET /collection_profiles GET /collection_profiles.json.
- #list ⇒ Object
-
#new ⇒ Object
GET /collection_profiles/new.
- #search ⇒ Object
-
#set_collection_profile ⇒ Object
private
Use callbacks to share common setup or constraints between actions.
-
#show ⇒ Object
GET /collection_profiles/1 GET /collection_profiles/1.json.
- #swap_form_attribute_types ⇒ Object
-
#update ⇒ Object
PATCH/PUT /collection_profiles/1 PATCH/PUT /collection_profiles/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
84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'app/controllers/collection_profiles_controller.rb', line 84 def autocomplete @collection_profiles = CollectionProfile.find_for_autocomplete(params.merge(project_id: sessions_current_project_id)).include(:taxon_names) data = @collection_profile.collect do |t| {id: t.id, label: ApplicationController.helpers.collection_profile_tag(t), response_values: { params[:method] => t.id }, label_html: ApplicationController.helpers.collection_profile_tag(t) } end render json: data end |
#collection_profile_params ⇒ Object (private)
Never trust parameters from the scary internet, only allow the white list through.
111 112 113 114 115 116 117 |
# File 'app/controllers/collection_profiles_controller.rb', line 111 def collection_profile_params params.require(:collection_profile).permit(:container_id, :otu_id, :conservation_status, :processing_state, :container_condition, :condition_of_labels, :identification_level, :arrangement_level, :data_quality, :computerization_level, :number_of_collection_objects, :number_of_containers, :collection_type, :force_update ) end |
#create ⇒ Object
POST /collection_profiles POST /collection_profiles.json
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/controllers/collection_profiles_controller.rb', line 33 def create @collection_profile = CollectionProfile.new(collection_profile_params) respond_to do |format| if @collection_profile.save format.html { redirect_to @collection_profile, notice: 'Collection profile was successfully created.' } format.json { render :show, status: :created, location: @collection_profile } else format.html { render :new } format.json { render json: @collection_profile.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /collection_profiles/1 DELETE /collection_profiles/1.json
68 69 70 71 72 73 74 |
# File 'app/controllers/collection_profiles_controller.rb', line 68 def destroy @collection_profile.destroy respond_to do |format| format.html { redirect_to collection_profiles_url } format.json { head :no_content } end end |
#edit ⇒ Object
GET /collection_profiles/1/edit
24 25 |
# File 'app/controllers/collection_profiles_controller.rb', line 24 def edit end |
#index ⇒ Object
GET /collection_profiles GET /collection_profiles.json
8 9 10 11 |
# File 'app/controllers/collection_profiles_controller.rb', line 8 def index @recent_objects = CollectionProfile.recent_from_project_id(sessions_current_project_id).order(updated_at: :desc).limit(10) render '/shared/data/all/index' end |
#list ⇒ Object
99 100 101 |
# File 'app/controllers/collection_profiles_controller.rb', line 99 def list @collection_profiles = CollectionProfile.order(:id).page(params[:page]) #.per(10) #.per(3) end |
#new ⇒ Object
GET /collection_profiles/new
19 20 21 |
# File 'app/controllers/collection_profiles_controller.rb', line 19 def new @collection_profile = CollectionProfile.new(collection_type: :dry) end |
#search ⇒ Object
76 77 78 79 80 81 82 |
# File 'app/controllers/collection_profiles_controller.rb', line 76 def search if params[:id].blank? redirect_to collection_profiles_path, alert: 'You must select an item from the list with a click or tab press before clicking show.' else redirect_to collection_profile_path(params[:id]) end end |
#set_collection_profile ⇒ Object (private)
Use callbacks to share common setup or constraints between actions.
105 106 107 108 |
# File 'app/controllers/collection_profiles_controller.rb', line 105 def set_collection_profile @collection_profile = CollectionProfile.with_project_id(sessions_current_project_id).find(params[:id]) @recent_object = @collection_profile end |
#show ⇒ Object
GET /collection_profiles/1 GET /collection_profiles/1.json
15 16 |
# File 'app/controllers/collection_profiles_controller.rb', line 15 def show end |
#swap_form_attribute_types ⇒ Object
27 28 29 |
# File 'app/controllers/collection_profiles_controller.rb', line 27 def swap_form_attribute_types render partial: 'collection_profile_collection_type_attributes_form', locals: { collection_profile: CollectionProfile.new(params.permit(:collection_type)) } end |
#update ⇒ Object
PATCH/PUT /collection_profiles/1 PATCH/PUT /collection_profiles/1.json
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/controllers/collection_profiles_controller.rb', line 49 def update respond_to do |format| if collection_profile_params['force_update'] == '0' flash['notice'] = 'Collection profile are not updatable unless forced, consider cloning this record or click force.' render :edit and return end if @collection_profile.update(collection_profile_params) format.html { redirect_to @collection_profile, notice: 'Collection profile was successfully updated.' } format.json { render :show, status: :ok, location: @collection_profile } else format.html { render :edit } format.json { render json: @collection_profile.errors, status: :unprocessable_entity } end end end |