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.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 4630552e02e..ac83c8e3256 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -282,6 +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_public_profile, -> { where(private_profile: false) }
+
+ def self.with_visible_profile(user)
+ return with_public_profile if user.nil?
+
+ if user.admin?
+ all
+ else
+ with_public_profile.or(where(id: user.id))
+ end
+ end
# Limits the users to those that have TODOs, optionally in the given state.
#