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

Merge branch 'validate-infohash' into 'master'

route to validate if infohash exists

See merge request !451
parents 3321e9d5 4c8ddfcf
No related branches found
No related tags found
No related merge requests found
...@@ -35,7 +35,7 @@ class V1::LearningObjectsController < ApplicationController ...@@ -35,7 +35,7 @@ class V1::LearningObjectsController < ApplicationController
before_action :set_new_learning_object, only: [:index, :submissions] before_action :set_new_learning_object, only: [:index, :submissions]
before_action :set_new_submission, only: :submit before_action :set_new_submission, only: :submit
before_action :set_submission, only: :show_submission before_action :set_submission, only: :show_submission
before_action :authorize!, except: [:create, :tagging, :untagging, :download, :magnetlink] before_action :authorize!, except: [:create, :tagging, :untagging, :download, :magnetlink, :validate]
before_action :set_paper_trail_whodunnit, except: [:index, :show] before_action :set_paper_trail_whodunnit, except: [:index, :show]
def index def index
...@@ -97,6 +97,15 @@ class V1::LearningObjectsController < ApplicationController ...@@ -97,6 +97,15 @@ class V1::LearningObjectsController < ApplicationController
render json: LearningObject.where(magnetlink: params[:magnetlink]) render json: LearningObject.where(magnetlink: params[:magnetlink])
end end
# GET /learning_objects/validate?infohash=""
def validate
infohash = LearningObject::Attachment.find_by_infohash(params["infohash"])
if infohash
render json: infohash, status: :ok
else
render status: :not_found
end
end
private private
......
...@@ -165,6 +165,9 @@ Rails.application.routes.draw do ...@@ -165,6 +165,9 @@ Rails.application.routes.draw do
resource :upload, module: 'learning_objects', only: :create resource :upload, module: 'learning_objects', only: :create
resource :publish, module: 'learning_objects', only: :create resource :publish, module: 'learning_objects', only: :create
end end
collection do
get 'validate'
end
resources :attachment, module: 'learning_objects', only: [:destroy, :update], on: :member resources :attachment, module: 'learning_objects', only: [:destroy, :update], on: :member
end end
......
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