Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-06-05 21:37:35 +0400
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-06-05 21:37:35 +0400
commit0fdce4a52b1a9ba9e0efd98f00e558e4f07daeb5 (patch)
tree9305a29f92c3d6763d6b7038ac65a71ec67e087e /app/models
parent4ca6ebf017e93686ee885ee1a28dc5c6934c9d39 (diff)
Refactor some search scopes to prevent wierd behaviour and PG::Error issues
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/models')
-rw-r--r--app/models/ability.rb2
-rw-r--r--app/models/group.rb10
-rw-r--r--app/models/namespace.rb8
-rw-r--r--app/models/project.rb6
4 files changed, 5 insertions, 21 deletions
diff --git a/app/models/ability.rb b/app/models/ability.rb
index df9b210dfca..c60aa2d622e 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -51,7 +51,7 @@ class Ability
nil
end
- if group && group.has_projects_accessible_to?(nil)
+ if group && group.public_profile?
[:read_group]
else
[]
diff --git a/app/models/group.rb b/app/models/group.rb
index 2e68779d367..e51e19ab60c 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -27,12 +27,6 @@ class Group < Namespace
mount_uploader :avatar, AttachmentUploader
- def self.accessible_to(user)
- accessible_ids = Project.accessible_to(user).pluck(:namespace_id)
- accessible_ids += user.groups.pluck(:id) if user
- where(id: accessible_ids)
- end
-
def human_name
name
end
@@ -77,4 +71,8 @@ class Group < Namespace
self.errors.add :avatar, "only images allowed"
end
end
+
+ def public_profile?
+ projects.public_only.any?
+ end
end
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index 7973eef7e1c..446e5f04c63 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -47,14 +47,6 @@ class Namespace < ActiveRecord::Base
def self.global_id
'GLN'
end
-
- def projects_accessible_to(user)
- projects.accessible_to(user)
- end
-
- def has_projects_accessible_to?(user)
- projects_accessible_to(user).present?
- end
def to_param
path
diff --git a/app/models/project.rb b/app/models/project.rb
index 758ef14703c..f92cc40642a 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -164,12 +164,6 @@ class Project < ActiveRecord::Base
where(visibility_level: visibility_levels)
end
- def accessible_to(user)
- accessible_ids = publicish(user).pluck(:id)
- accessible_ids += user.authorized_projects.pluck(:id) if user
- where(id: accessible_ids)
- end
-
def with_push
includes(:events).where('events.action = ?', Event::PUSHED)
end