Commit 3058a8fa authored by Douwe Maan's avatar Douwe Maan

Fix "Shared projects" tab

parent fd8d44ca
...@@ -44,7 +44,7 @@ class GroupsController < Groups::ApplicationController ...@@ -44,7 +44,7 @@ class GroupsController < Groups::ApplicationController
@projects = @projects.sort(@sort = params[:sort]) @projects = @projects.sort(@sort = params[:sort])
@projects = @projects.page(params[:page]).per(PER_PAGE) if params[:filter_projects].blank? @projects = @projects.page(params[:page]).per(PER_PAGE) if params[:filter_projects].blank?
@shared_projects = GroupProjectsFinder.new(group, shared: true).execute(current_user) @shared_projects = GroupProjectsFinder.new(group, only_shared: true).execute(current_user)
respond_to do |format| respond_to do |format|
format.html format.html
...@@ -77,7 +77,7 @@ class GroupsController < Groups::ApplicationController ...@@ -77,7 +77,7 @@ class GroupsController < Groups::ApplicationController
end end
def projects def projects
@projects = @projects.sorted_by_activity.page(params[:page]) @projects = @group.projects.page(params[:page])
end end
def update def update
......
...@@ -13,29 +13,29 @@ class GroupProjectsFinder < UnionFinder ...@@ -13,29 +13,29 @@ class GroupProjectsFinder < UnionFinder
private private
def group_projects(current_user) def group_projects(current_user)
include_owned = @options.fetch(:owned, true) only_owned = @options.fetch(:only_owned, false)
include_shared = @options.fetch(:shared, true) only_shared = @options.fetch(:only_shared, false)
projects = [] projects = []
if current_user if current_user
if @group.users.include?(current_user) if @group.users.include?(current_user)
projects << @group.projects if include_owned projects << @group.projects unless only_shared
projects << @group.shared_projects if include_shared projects << @group.shared_projects unless only_owned
else else
if include_owned unless only_shared
projects << @group.projects.visible_to_user(current_user) projects << @group.projects.visible_to_user(current_user)
projects << @group.projects.public_to_user(current_user) projects << @group.projects.public_to_user(current_user)
end end
if include_shared unless only_owned
projects << @group.shared_projects.visible_to_user(current_user) projects << @group.shared_projects.visible_to_user(current_user)
projects << @group.shared_projects.public_to_user(current_user) projects << @group.shared_projects.public_to_user(current_user)
end end
end end
else else
projects << @group.projects.public_only if include_owned projects << @group.projects.public_only unless only_shared
projects << @group.shared_projects.public_only if include_shared projects << @group.shared_projects.public_only unless only_owned
end end
projects projects
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment