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

returning all objects to curator

parent c8a1b659
No related branches found
No related tags found
No related merge requests found
......@@ -7,10 +7,10 @@ module SubmissionController
before_action :authorize!
end
#def show_all_submissions
# learning_objects = paginate Learning_Object.where(state: LearningObject.states[:submitted])
# render json: learning_objects
#end
def submissions
learning_objects = paginate LearningObject.where(state: LearningObject.states[:submitted])
render json: learning_objects
end
def submit
return render status: :ok if @learning_object.submitted?
......
......@@ -11,9 +11,9 @@ class V1::LearningObjectsController < ApplicationController
include ::StageableController
include ::SubmissionController
before_action :authenticate_user!, only: [:create, :update, :destroy, :tagging, :untagging]
before_action :authenticate_user!, only: [:create, :update, :destroy, :tagging, :untagging, :submit, :submission]
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 :set_new_learning_object, only: [:index, :submissions]
before_action :set_new_submission, only: :submit
before_action :authorize!, except: [:create, :tagging, :untagging, :download, :magnetlink]
before_action :set_paper_trail_whodunnit, except: [:index, :show]
......
......@@ -100,6 +100,13 @@ class User < ApplicationRecord
false
end
def is_curator?
roles.each do |role|
return true if role.name == 'curator'
end
false
end
def is_moderator?
roles.each do |role|
return true if role.name == 'moderator'
......
......@@ -59,6 +59,10 @@ class ApplicationPolicy
user.is_admin? || user.is_moderator?
end
def user_can_curate?
user.is_curator?
end
class Scope < ApplicationPolicy
attr_reader :user, :scope
......
......@@ -4,4 +4,9 @@ module SubmissionPolicy
record if owns?
end
def submissions?
return false if user.nil?
record if user_can_curate?
end
end
......@@ -60,7 +60,7 @@ Rails.application.routes.draw do
concern :submission do
collection do
get :show_all_submissions
get :submissions
end
member do
post :submit
......
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