Class: RolesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- RolesController
- Defined in:
- app/controllers/roles_controller.rb
Constant Summary
Constants included from ProjectsHelper
ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION
Instance Method Summary collapse
-
#create ⇒ Object
POST /roles.json.
-
#destroy ⇒ Object
DELETE /roles/1.json.
- #edit ⇒ Object
-
#filter_params ⇒ Object
private
TODO: move logic to Filter.
-
#index ⇒ Object
GET /roles.json.
- #new ⇒ Object
- #role_params ⇒ Object private
- #set_role ⇒ Object private
-
#update ⇒ Object
PATCH/PUT /roles/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
#create ⇒ Object
POST /roles.json
25 26 27 28 29 30 31 32 |
# File 'app/controllers/roles_controller.rb', line 25 def create @role = Role.new(role_params) if @role.save render action: :show, status: :created, location: @role. else render json: @role.errors, status: :unprocessable_entity end end |
#destroy ⇒ Object
DELETE /roles/1.json
44 45 46 47 48 49 50 51 |
# File 'app/controllers/roles_controller.rb', line 44 def destroy @role.destroy if @role.destroyed? head :no_content else render json: @role.errors, status: :unprocessable_entity end end |
#edit ⇒ Object
20 21 22 |
# File 'app/controllers/roles_controller.rb', line 20 def edit @role = Role.find_by_id(params[:id]). end |
#filter_params ⇒ Object (private)
TODO: move logic to Filter
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'app/controllers/roles_controller.rb', line 82 def filter_params add_project_id = false role_types = [params[:role_type]].flatten.compact.map(&:safe_constantize) if params[:object_global_id].present? role_types << GlobalID::Locator.locate(params[:object_global_id]).class end h = params.permit( :role_type, :object_global_id, :role_object_id, :role_object_type, role_object_id: [], role_object_type: [], role_type: []) # If any role role_types.flatten.compact.uniq.each do |t| if t.is_community? h['project_id'] = sessions_current_project_id break end end h end |
#index ⇒ Object
GET /roles.json
9 10 11 12 13 14 |
# File 'app/controllers/roles_controller.rb', line 9 def index @roles = Queries::Role::Filter.new(params) .all .page(params[:page]) .per(params[:per]) end |
#new ⇒ Object
16 17 18 |
# File 'app/controllers/roles_controller.rb', line 16 def new @role = Role.new(role_params) end |
#role_params ⇒ Object (private)
108 109 110 111 112 113 114 115 116 117 |
# File 'app/controllers/roles_controller.rb', line 108 def role_params params.require(:role).permit( :position, :type, :person_id, :role_object_id, :role_object_type, :organization_id, :annotated_global_entity) # not supported yet end |
#set_role ⇒ Object (private)
76 77 78 79 |
# File 'app/controllers/roles_controller.rb', line 76 def set_role # TODO: confirm Role is in project if annotated object is provided @role = Role.find(params[:id]) end |
#update ⇒ Object
PATCH/PUT /roles/1.json
35 36 37 38 39 40 41 |
# File 'app/controllers/roles_controller.rb', line 35 def update if @role.update(role_params) render action: 'show', status: :created, location: @role. else render json: @role.errors, status: :unprocessable_entity end end |