Skip to content
Snippets Groups Projects
Commit ca422297 authored by Marcela Ribeiro de Oliveira's avatar Marcela Ribeiro de Oliveira
Browse files

Now an user can add subjects separately

parent 138dfaad
No related branches found
No related tags found
No related merge requests found
module SubjectableController
extend ActiveSupport::Concern
included do
before_action :authenticate_user!, only: [:subjecting, :unsubjecting]
end
# POST /v1/learning_objects/1/subjects
# POST /v1/learning_objects/1/subjects.json
def subjecting
subjectable.add_subjects(ids: params[:subjects])
render json: subjectable.subjects, status: :created
end
# DELETE /v1/learning_objects/1/subjects
# DELETE /v1/learning_objects/1/subjects.json
#def unsubjecting
# @owner.remove_subjects(subject_params[:id])
# render json: subjects.tags, status: :ok
#end
protected
def subjectable
raise NotImplementedError
end
end
...@@ -6,11 +6,12 @@ class V1::LearningObjectsController < ApplicationController ...@@ -6,11 +6,12 @@ class V1::LearningObjectsController < ApplicationController
include ::Paginator include ::Paginator
include ::DeletedObjectsController include ::DeletedObjectsController
include ::HighlightsController include ::HighlightsController
include ::SubjectableController
before_action :authenticate_user!, except: [:create, :index, :show] before_action :authenticate_user!, except: [:create, :index, :show]
before_action :set_learning_object, only: [:show, :update, :destroy] before_action :set_learning_object, only: [:show, :update, :destroy]
before_action :set_new_learning_object, only: :index before_action :set_new_learning_object, only: :index
before_action :authorize!, except: [:create, :tagging, :untagging] before_action :authorize!, except: [:create, :tagging, :untagging, :subjecting, :unsubjecting]
def index def index
learning_objects = paginate LearningObject.includes(:tags, :publisher, :language, :license, :subjects, :educational_stages, :reviews) learning_objects = paginate LearningObject.includes(:tags, :publisher, :language, :license, :subjects, :educational_stages, :reviews)
...@@ -69,6 +70,7 @@ class V1::LearningObjectsController < ApplicationController ...@@ -69,6 +70,7 @@ class V1::LearningObjectsController < ApplicationController
def highlights_resource; LearningObject; end def highlights_resource; LearningObject; end
def sociable; set_learning_object; end def sociable; set_learning_object; end
def taggable; set_learning_object; end def taggable; set_learning_object; end
def subjectable; set_learning_object; end
# Use callbacks to share common setup or constraints between actions. # Use callbacks to share common setup or constraints between actions.
def set_learning_object def set_learning_object
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment