Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cleaning-portalmec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Richard Fernando Heise Ferreira
cleaning-portalmec
Commits
ba78b934
Commit
ba78b934
authored
8 years ago
by
Israel Barreto Sant'Anna
Browse files
Options
Downloads
Patches
Plain Diff
Filtered empty collections from index action
Signed-off-by:
Israel Barreto Sant'Anna
<
ibsa14@inf.ufpr.br
>
parent
a320ea57
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/controllers/v1/collections_controller.rb
+1
-1
1 addition, 1 deletion
app/controllers/v1/collections_controller.rb
app/policies/collection_policy.rb
+2
-8
2 additions, 8 deletions
app/policies/collection_policy.rb
with
3 additions
and
9 deletions
app/controllers/v1/collections_controller.rb
+
1
−
1
View file @
ba78b934
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
app/policies/collection_policy.rb
+
2
−
8
View file @
ba78b934
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment