diff options
author | Mike Greiling <mike@pixelcog.com> | 2016-12-08 01:35:53 +0300 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2016-12-10 09:57:23 +0300 |
commit | 54a1193d790ae40fea5db1d8596c12fbc7a93576 (patch) | |
tree | 98123332599e0d493a92901317f14ae8c5d6e672 /app/finders/snippets_finder.rb | |
parent | b65d3e1132762b9e1a39ce908b3b481f92d9a10c (diff) |
add scope filters to project snippets page
Diffstat (limited to 'app/finders/snippets_finder.rb')
-rw-r--r-- | app/finders/snippets_finder.rb | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/app/finders/snippets_finder.rb b/app/finders/snippets_finder.rb index 00ff1611039..99f1e73c800 100644 --- a/app/finders/snippets_finder.rb +++ b/app/finders/snippets_finder.rb @@ -8,7 +8,7 @@ class SnippetsFinder when :by_user then by_user(current_user, params[:user], params[:scope]) when :by_project - by_project(current_user, params[:project]) + by_project(current_user, params[:project], params[:scope]) end end @@ -47,14 +47,30 @@ class SnippetsFinder end end - def by_project(current_user, project) + def by_project(current_user, project, scope) snippets = project.snippets.fresh if current_user if project.team.member?(current_user) || current_user.admin? - snippets + case scope + when 'are_internal' then + snippets.are_internal + when 'are_private' then + snippets.are_private + when 'are_public' then + snippets.are_public + else + snippets + end else - snippets.public_and_internal + case scope + when 'are_internal' then + snippets.are_internal + when 'are_public' then + snippets.are_public + else + snippets.public_and_internal + end end else snippets.are_public |