Class: AnnotationsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/annotations_controller.rb

Constant Summary

Constants included from ProjectsHelper

ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION

Instance Method Summary collapse

Methods included from RedirectHelper

#destroy_redirect

Methods included from RequestType

#json_request?

Methods included from LogRecent

#log_user_recent_route

Methods included from Cookies

#digest_cookie, #digested_cookie_exists?

Methods included from Whitelist

#whitelist_constantize

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

#intercept_api

Methods included from TokenAuthentication

#intercept_project, #intercept_user, #intercept_user_or_project, #project_token_authenticate, #token_authenticate

Instance Method Details

#metadataObject

GET /annotations/:global_id/metadata



6
7
8
9
10
# File 'app/controllers/annotations_controller.rb', line 6

def 
  @object = GlobalID::Locator.locate(params.require(:global_id))
  render(json: { success: false}, status: :not_found) and return if @object.nil?
  render(json: { 'message' => 'Record not found' }, status: :unauthorized) if !@object.is_community? && @object.project_id != sessions_current_project_id
end

#moveObject

POST



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/annotations_controller.rb', line 17

def move
  @from_object = GlobalID::Locator.locate(params.require(:from_global_id))
  @to_object = GlobalID::Locator.locate(params.require(:to_global_id))

  render(json: { success: false}, status: :not_found) and return if @from_object.nil? || @to_object.nil?
 
  e = @from_object.move_annotations(
    to_object: @to_object,
    except: params[:except],
    only: params[:only]
  )
  
  if e.empty?
    render json: {from_object: @from_object, to_object: @to_object}
  else
    render json: {success: false, errors: e }, status: :unprocessable_entity
  end
end

#typesObject

GET /annotations/types (JSON)



13
14
# File 'app/controllers/annotations_controller.rb', line 13

def types
end