Skip to content
Snippets Groups Projects
Commit 17d33081 authored by lmtd21's avatar lmtd21
Browse files

Issue #29: FIX draft attributes

parent e33813ba
No related branches found
No related tags found
1 merge request!27Issue #29: FIX draft attributes
Pipeline #32155 failed
......@@ -75,6 +75,12 @@ class V1::LearningObjectsController < ApplicationController
# PATCH/PUT /learning_objects/1.json
def update
lo_params = learning_object_params
language_ids_lo = params[:language_ids]
@learning_object.language_ids = language_ids_lo
current_user.tag(@learning_object, with: params[:tags].map { |t| t['name'] })
@learning_object.add_educational_stages(ids: params[:educational_stages]) unless params[:educational_stages].nil?
@learning_object.update_subjects(ids: params[:subjects]) unless params[:subjects].nil?
if !lo_params[:object_type_id].blank? && lo_params[:object_type_id] != @learning_object.object_type_id && lo_params[:link].blank?
change_object_type_id = true
end
......@@ -98,6 +104,7 @@ class V1::LearningObjectsController < ApplicationController
# DELETE /learning_objects/1
# DELETE /learning_objects/1.json
def destroy
@learning_object.update(state: LearningObject.states[:deleted])
@learning_object.destroy
response = { 'status': 'deleted' }
render status: :ok, json: response
......@@ -162,8 +169,8 @@ class V1::LearningObjectsController < ApplicationController
elsif !extra_params[:tags].nil?
current_user.tag(learning_object, with: extra_params[:tags].map { |t| t['name'] })
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?
learning_object.add_subjects(ids: params[:subjects]) unless 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
......
......@@ -32,7 +32,6 @@ module Subjectable
def add_subjects(ids: [])
ids.each do |subject_id|
subject = Subject.find(subject_id)
SubjectRelation.where(subject: subject, subjectable: self).first_or_create
self.subjects << subject
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment