Skip to content
Snippets Groups Projects
Commit 3a92a700 authored by Israel Barreto Sant'Anna's avatar Israel Barreto Sant'Anna
Browse files

Merge branch 'fix-collection-index' into 'master'

Fix collection index

See merge request !360
parents aed7c67d 0ed6ca52
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,7 @@ class V1::CollectionsController < ApplicationController
# GET /v1/collections
# GET /v1/collections.json
def index
collections = paginate Collection
collections = paginate policy_scope(Collection)
render json: collections
end
......
......@@ -6,17 +6,11 @@ class CollectionPolicy < ApplicationPolicy
include StageablePolicy
class Scope < Scope
def initialize(user, user_id, scope)
@user = user
@user_id = user_id
@scope = scope
end
def resolve
if @user.try(:id) == @user_id || @user.try(:is_admin?)
if !user.nil? && user.is_admin?
scope.all
else
scope.where(privacy: 'public')
scope.includes(:collection_items).where.not(:collection_items => {:collection_id => nil}).where(privacy: 'public')
end
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