Class: ConveyancesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- ConveyancesController
- Defined in:
- app/controllers/conveyances_controller.rb
Constant Summary
Constants included from ProjectsHelper
ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION
Instance Method Summary collapse
- #api_index ⇒ Object
- #api_show ⇒ Object
- #autocomplete ⇒ Object
- #conveyance_params ⇒ Object private
-
#create ⇒ Object
POST /conveyances or /conveyances.json.
-
#destroy ⇒ Object
DELETE /conveyances/1 or /conveyances/1.json.
-
#edit ⇒ Object
GET /conveyances/1/edit.
-
#index ⇒ Object
GET /conveyances or /conveyances.json.
- #list ⇒ Object
- #navigation ⇒ Object
- #new ⇒ Object
- #select_options ⇒ Object
- #set_conveyance ⇒ Object private
-
#show ⇒ Object
GET /conveyances/1 or /conveyances/1.json.
-
#update ⇒ Object
PATCH/PUT /conveyances/1 or /conveyances/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_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
28 29 30 31 32 33 34 35 |
# File 'app/controllers/conveyances_controller.rb', line 28 def api_index @conveyances = Queries::Conveyance::Filter.new(params.merge!(api: true)).all .where(project_id: sessions_current_project_id) .order('conveyances.conveyance_object_type, conveyances.conveyance_object_id, conveyances.position') .page(params[:page]) .per(params[:per]) render '/conveyances/api/v1/index' end |
#api_show ⇒ Object
37 38 39 |
# File 'app/controllers/conveyances_controller.rb', line 37 def api_show render '/conveyances/api/v1/show' end |
#autocomplete ⇒ Object
95 96 97 98 99 100 |
# File 'app/controllers/conveyances_controller.rb', line 95 def autocomplete @conveyances = Queries::Conveyance::Autocomplete.new( params[:term], project_id: sessions_current_project_id, polymorphic_types: params[:polymorphic_types_allowed] ).autocomplete end |
#conveyance_params ⇒ Object (private)
114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'app/controllers/conveyances_controller.rb', line 114 def conveyance_params params.require(:conveyance).permit( :sound_id, :conveyance_object_id, :conveyance_object_type, :position, :start_time, :end_time, sound_attributes: [ :sound_file, :name ] ) end |
#create ⇒ Object
POST /conveyances or /conveyances.json
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/controllers/conveyances_controller.rb', line 58 def create @conveyance = Conveyance.new(conveyance_params) respond_to do |format| if @conveyance.save format.html { redirect_to @conveyance, notice: 'Conveyance was successfully created.' } format.json { render :show, status: :created, location: @conveyance } else format.html { render :new, status: :unprocessable_entity } format.json { render json: @conveyance.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /conveyances/1 or /conveyances/1.json
86 87 88 89 90 91 92 93 |
# File 'app/controllers/conveyances_controller.rb', line 86 def destroy @conveyance.destroy! respond_to do |format| format.html { redirect_to conveyances_path, status: :see_other, notice: 'Conveyance was successfully destroyed.' } format.json { head :no_content } end end |
#edit ⇒ Object
GET /conveyances/1/edit
54 55 |
# File 'app/controllers/conveyances_controller.rb', line 54 def edit end |
#index ⇒ Object
GET /conveyances or /conveyances.json
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/conveyances_controller.rb', line 9 def index respond_to do |format| format.html { @recent_objects = Conveyance.where( project_id: sessions_current_project_id ).order(updated_at: :desc).limit(10) render '/shared/data/all/index' } format.json { @conveyances = Queries::Conveyance::Filter.new(params) .all .where(project_id: sessions_current_project_id) .where(Queries::Annotator::polymorphic_params(params, Conveyance)) # TODO: -> configured? .page(params[:page]) .per(params[:per]) } end end |
#list ⇒ Object
41 42 43 |
# File 'app/controllers/conveyances_controller.rb', line 41 def list @conveyances = Conveyance.where(project_id: sessions_current_project_id).page(params[:page]) end |
#navigation ⇒ Object
102 103 |
# File 'app/controllers/conveyances_controller.rb', line 102 def end |
#new ⇒ Object
49 50 51 |
# File 'app/controllers/conveyances_controller.rb', line 49 def new @conveyance = Conveyance.new end |
#select_options ⇒ Object
105 106 107 |
# File 'app/controllers/conveyances_controller.rb', line 105 def @conveyances = Conveyance.select_optimized(sessions_current_user_id, sessions_current_project_id, params.require(:target)) end |
#set_conveyance ⇒ Object (private)
110 111 112 |
# File 'app/controllers/conveyances_controller.rb', line 110 def set_conveyance @conveyance = Conveyance.find(params[:id]) end |
#show ⇒ Object
GET /conveyances/1 or /conveyances/1.json
46 47 |
# File 'app/controllers/conveyances_controller.rb', line 46 def show end |
#update ⇒ Object
PATCH/PUT /conveyances/1 or /conveyances/1.json
73 74 75 76 77 78 79 80 81 82 83 |
# File 'app/controllers/conveyances_controller.rb', line 73 def update respond_to do |format| if @conveyance.update(conveyance_params) format.html { redirect_to @conveyance, notice: 'Conveyance was successfully updated.' } format.json { render :show, status: :ok, location: @conveyance } else format.html { render :edit, status: :unprocessable_entity } format.json { render json: @conveyance.errors, status: :unprocessable_entity } end end end |