Class: Tasks::Shared::RelatedDataController

Inherits:
ApplicationController
  • Object
show all
Includes:
TaskControllerConfiguration
Defined in:
app/controllers/tasks/shared/related_data_controller.rb

Instance Method Summary collapse

Methods included from TaskControllerConfiguration

#set_is_task_controller

Instance Method Details

#community_record?(object) ⇒ Boolean (private)

A nil project_id alone is not trusted to mean community (it can be bad data): the record must declare it, e.g. a community Template, or an Identifier on a Source. Fails closed for everything else.

Returns:

  • (Boolean)


24
25
26
27
28
# File 'app/controllers/tasks/shared/related_data_controller.rb', line 24

def community_record?(object)
  (object.respond_to?(:is_community?) && object.is_community?) ||
    (object.respond_to?(:annotates_community_object?) &&
      object.annotates_community_object?)
end

#index ⇒ Object



6
7
# File 'app/controllers/tasks/shared/related_data_controller.rb', line 6

def index
end

#set_object ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'app/controllers/tasks/shared/related_data_controller.rb', line 9

def set_object
  @object = GlobalID::Locator.locate(params[:object_global_id])

  if @object.nil? || (@object.respond_to?(:project_id) &&
      @object.project_id != sessions_current_project_id &&
      !(@object.project_id.nil? && community_record?(@object)))
    render status: 404 and return
  end
end