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

Merge branch 'bugs' into 'master'

#252 - bugs

See merge request !434
parents 283e611b 2476b3d0
No related branches found
No related tags found
No related merge requests found
......@@ -49,8 +49,11 @@ class V1::LearningObjectsController < ApplicationController
# PATCH/PUT /learning_objects/1
# PATCH/PUT /learning_objects/1.json
def update
if !learning_object_params[:object_type_id].blank? && learning_object_params[:object_type_id] != @learning_object.object_type_id && learning_object_params[:link].blank?
change_object_type_id = true
end
if @learning_object.update(learning_object_params)
learning_object_associations(@learning_object)
learning_object_associations(@learning_object, change_object_type_id)
publisher = LearningObjectPublisher.new(DspaceService.create_client)
publisher.update_dspace(@learning_object)
......@@ -108,7 +111,7 @@ class V1::LearningObjectsController < ApplicationController
params[:learning_object].permit(subjects: [], educational_stages: [], tags: [:name])
end
def learning_object_associations(learning_object)
def learning_object_associations(learning_object, change_object_type_id)
if extra_params[:tags] == []
current_user.untag(learning_object, with: @learning_object.tags.map { |t| t['name'] })
elsif !extra_params[:tags].nil?
......@@ -116,6 +119,10 @@ class V1::LearningObjectsController < ApplicationController
end
learning_object.add_subjects(ids: extra_params[:subjects]) unless extra_params[:subjects].nil?
learning_object.add_educational_stages(ids: extra_params[:educational_stages]) unless extra_params[:educational_stages].nil?
if change_object_type_id
learning_object.link = nil
end
end
def authorize!
......
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