Class: DepictionsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- DepictionsController
- Defined in:
- app/controllers/depictions_controller.rb
Constant Summary
Constants included from ProjectsHelper
ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION
Instance Method Summary collapse
- #api_gallery ⇒ Object
-
#api_index ⇒ Object
GET /api/v1/otus.
- #api_show ⇒ Object
-
#create ⇒ Object
POST /depictions POST /depictions.json.
- #depiction_params ⇒ Object private
-
#destroy ⇒ Object
DELETE /depictions/1 DELETE /depictions/1.json.
-
#download ⇒ Object
GET /depictions/download.
-
#edit ⇒ Object
GET /depictions/1/edit.
-
#index ⇒ Object
GET /depictions GET /depictions.json.
- #list ⇒ Object
-
#new ⇒ Object
GET /depictions/new.
- #set_depiction ⇒ Object private
-
#show ⇒ Object
GET /depictions/1 GET /depictions/1.json.
-
#sort ⇒ Object
PATCH /sort?depiction_ids[]=1&depiction_ids=2.json.
-
#update ⇒ Object
PATCH/PUT /depictions/1 PATCH/PUT /depictions/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
#api_gallery ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'app/controllers/depictions_controller.rb', line 51 def api_gallery @depictions = Queries::Depiction::Filter.new(params.merge!(api: true)).all .where(project_id: sessions_current_project_id) .order('depictions.id') .page(params[:page]) .per(params[:per]) render '/depictions/api/v1/gallery' end |
#api_index ⇒ Object
GET /api/v1/otus
42 43 44 45 46 47 48 49 |
# File 'app/controllers/depictions_controller.rb', line 42 def api_index @depictions = Queries::Depiction::Filter.new(params.merge!(api: true)).all .where(project_id: sessions_current_project_id) .order('depictions.id') .page(params[:page]) .per(params[:per]) render '/depictions/api/v1/index' end |
#api_show ⇒ Object
37 38 39 |
# File 'app/controllers/depictions_controller.rb', line 37 def api_show render '/depictions/api/v1/show' end |
#create ⇒ Object
POST /depictions POST /depictions.json
71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'app/controllers/depictions_controller.rb', line 71 def create @depiction = Depiction.new(depiction_params) respond_to do |format| if @depiction.save format.html { redirect_to @depiction, notice: 'Depiction was successfully created.' } format.json { render :show, status: :created, location: @depiction } else format.html { render :new } format.json { render json: @depiction.errors, status: :unprocessable_entity } end end end |
#depiction_params ⇒ Object (private)
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'app/controllers/depictions_controller.rb', line 137 def depiction_params params.require(:depiction).permit( :depiction_object_id, :depiction_object_type, :annotated_global_entity, :caption, :is_metadata_depiction, :image_id, :figure_label, image_attributes: [ :image_file, tags_attributes: [:id, :keyword_id, :_destroy], identifiers_attributes: [:id, :namespace_id, :identifier, :type, :_destroy] ], sqed_depiction_attributes: [:id, :_destroy, :boundary_color, :boundary_finder, :has_border, :layout, metadata_map: {}] ) end |
#destroy ⇒ Object
DELETE /depictions/1 DELETE /depictions/1.json
100 101 102 103 104 105 106 |
# File 'app/controllers/depictions_controller.rb', line 100 def destroy @depiction.destroy respond_to do |format| format.html { redirect_to depictions_url, notice: 'Depiction was successfully destroyed.' } format.json { head :no_content } end end |
#download ⇒ Object
GET /depictions/download
126 127 128 129 |
# File 'app/controllers/depictions_controller.rb', line 126 def download send_data Export::CSV.generate_csv( Depiction.where(project_id: sessions_current_project_id)), type: 'text', filename: "depictions_#{DateTime.now}.tsv" end |
#edit ⇒ Object
GET /depictions/1/edit
66 67 |
# File 'app/controllers/depictions_controller.rb', line 66 def edit end |
#index ⇒ Object
GET /depictions GET /depictions.json
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/depictions_controller.rb', line 9 def index respond_to do |format| format.html { @recent_objects = Depiction.where(project_id: sessions_current_project_id).order(updated_at: :desc).limit(10) render '/shared/data/all/index' } format.json { @depictions = Queries::Depiction::Filter.new(params) .all .where(project_id: sessions_current_project_id) .where(Queries::Annotator::polymorphic_params(params, Depiction)) .page(params[:page]) .per(params[:per]) } end end |
#list ⇒ Object
27 28 29 |
# File 'app/controllers/depictions_controller.rb', line 27 def list @depictions = Depiction.where(project_id: sessions_current_project_id).page(params[:page]) end |
#new ⇒ Object
GET /depictions/new
61 62 63 |
# File 'app/controllers/depictions_controller.rb', line 61 def new @depiction = Depiction.new end |
#set_depiction ⇒ Object (private)
133 134 135 |
# File 'app/controllers/depictions_controller.rb', line 133 def set_depiction @depiction = Depiction.where(project_id: sessions_current_project_id).find(params[:id]) end |
#show ⇒ Object
GET /depictions/1 GET /depictions/1.json
33 34 35 |
# File 'app/controllers/depictions_controller.rb', line 33 def show @depiction.sqed_depiction.preprocess(false) if @depiction.sqed_depiction end |
#sort ⇒ Object
PATCH /sort?depiction_ids[]=1&depiction_ids=2.json
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'app/controllers/depictions_controller.rb', line 109 def sort respond_to do |format| begin params.require(:depiction_ids).each_with_index do |d, i| Depiction.find(d).update_column(:position, i + 1) end rescue ActionController::ParameterMissing format.json { render json: {success: false}, status: :unprocessable_entity and return } rescue ActiveRecord::RecordInvalid format.json { render json: {success: false}, status: :unprocessable_entity and return } end format.json { render json: {success: true}, status: :ok and return } end end |
#update ⇒ Object
PATCH/PUT /depictions/1 PATCH/PUT /depictions/1.json
86 87 88 89 90 91 92 93 94 95 96 |
# File 'app/controllers/depictions_controller.rb', line 86 def update respond_to do |format| if @depiction.update(depiction_params) format.html { redirect_to @depiction, notice: 'Depiction was successfully updated.' } format.json { render :show, status: :ok, location: @depiction } else format.html { render :edit } format.json { render json: @depiction.errors, status: :unprocessable_entity } end end end |