summaryrefslogtreecommitdiff
path: root/app/models/user.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/user.rb')
-rw-r--r--app/models/user.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index cfb8cd3819d..ac83c8e3256 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -282,15 +282,17 @@ class User < ApplicationRecord
scope :for_todos, -> (todos) { where(id: todos.select(:user_id)) }
scope :with_emails, -> { preload(:emails) }
scope :with_dashboard, -> (dashboard) { where(dashboard: dashboard) }
- scope :with_visible_profile, -> (user) {
- if user.nil?
- where(private_profile: false)
- elsif user.admin?
+ scope :with_public_profile, -> { where(private_profile: false) }
+
+ def self.with_visible_profile(user)
+ return with_public_profile if user.nil?
+
+ if user.admin?
all
else
- where(private_profile: false).or where(id: user.id)
+ with_public_profile.or(where(id: user.id))
end
- }
+ end
# Limits the users to those that have TODOs, optionally in the given state.
#