Skip to content
Snippets Groups Projects
Commit b22d7ffb authored by Clarissa's avatar Clarissa
Browse files

Merge branch 'master' of gitlab.c3sl.ufpr.br:portalmec/portalmec

parents 2cb84884 99536400
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,7 @@ class V1::LearningObjectsController < ApplicationController
before_action :authenticate_user!, only: [:create, :update, :destroy, :tagging, :untagging]
before_action :set_learning_object, only: [:show, :update, :destroy, :subjecting, :unsubjecting, :add_stages, :remove_stages]
before_action :set_new_learning_object, only: :index
before_action :authorize!, except: [:create, :tagging, :untagging, :download]
before_action :authorize!, except: [:create, :tagging, :untagging, :download, :magnetlink]
before_action :set_paper_trail_whodunnit, except: [:index, :show]
def index
......@@ -67,6 +67,12 @@ class V1::LearningObjectsController < ApplicationController
render status: :ok
end
# GET /v1/learning_objects/magnetlink/:magnetlink
def magnetlink
render json: LearningObject.where(magnetlink: params[:magnetlink])
end
private
def deleted_resource; LearningObject; end
......@@ -94,7 +100,7 @@ class V1::LearningObjectsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def learning_object_params
return nil if params[:learning_object].nil?
params[:learning_object].permit(:author, :name, :curator, :object_type_id, :description, :license_id, :thumbnail, :software, :language_id, :link)
params[:learning_object].permit(:author, :name, :curator, :object_type_id, :description, :license_id, :thumbnail, :software, :language_id, :link, :magnetlink)
end
def extra_params
......
......@@ -53,7 +53,8 @@ class LearningObjectSerializer < ActiveModel::Serializer
:complained,
:shares_count,
:created_at,
:updated_at
:updated_at,
:magnetlink
belongs_to :publisher
has_many :tags
......
......@@ -154,5 +154,6 @@ Rails.application.routes.draw do
get '/subjects', to: 'subjects#index'
get '/educational_stages', to: 'educational_stages#index'
get '/activities/me', to: 'activities#me'
get 'learning_objects/magnetlink/:magnetlink', to: 'learning_objects#magnetlink', as: 'magnetlink_learning_objects'
end
end
class AddMagnetlinkToLearningObject < ActiveRecord::Migration[5.0]
def change
add_column :learning_objects, :magnetlink, :string
end
end
\ No newline at end of file
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