mirror of
https://github.com/opf/openproject.git
synced 2026-06-13 19:20:00 +00:00
Use active_admin? instead of admin?
This commit is contained in:
committed by
Oliver Günther
parent
5c2801646f
commit
e709bed089
@@ -34,7 +34,7 @@ module Capabilities::Scopes
|
||||
|
||||
class_methods do
|
||||
def visible(user = User.current)
|
||||
scope = if user.admin?
|
||||
scope = if user.active_admin?
|
||||
all
|
||||
else
|
||||
where(context_id: nil)
|
||||
|
||||
@@ -34,9 +34,13 @@ module CustomFields::Scopes
|
||||
|
||||
class_methods do
|
||||
def visible(user = User.current)
|
||||
known_subclasses
|
||||
.inject(none) do |scope, klass|
|
||||
scope.or(where(type: klass.name).and(klass.visible(user)))
|
||||
if user.active_admin?
|
||||
all
|
||||
else
|
||||
known_subclasses
|
||||
.inject(none) do |scope, klass|
|
||||
scope.or(where(type: klass.name).and(klass.visible(user)))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ module GroupCustomFields::Scopes
|
||||
|
||||
class_methods do
|
||||
def visible(user = User.current)
|
||||
if user.admin?
|
||||
if user.active_admin?
|
||||
all
|
||||
else
|
||||
where(admin_only: false)
|
||||
|
||||
@@ -35,7 +35,7 @@ module Members::Scopes
|
||||
class_methods do
|
||||
# Find all members visible to the inquiring user
|
||||
def visible(user = User.current)
|
||||
if user.admin?
|
||||
if user.active_admin?
|
||||
visible_for_admins
|
||||
else
|
||||
visible_for_non_admins(user)
|
||||
|
||||
@@ -42,7 +42,7 @@ module Principals::Scopes
|
||||
|
||||
class_methods do
|
||||
def visible(user = ::User.current)
|
||||
if user.allowed_globally?(:view_all_principals) || user.admin?
|
||||
if user.allowed_globally?(:view_all_principals)
|
||||
all
|
||||
else
|
||||
in_visible_project_or_me_or_same_groups(user)
|
||||
|
||||
@@ -56,7 +56,7 @@ class ProjectCustomField < CustomField
|
||||
|
||||
class << self
|
||||
def visible(user = User.current, project: nil)
|
||||
if user.admin?
|
||||
if user.active_admin?
|
||||
all
|
||||
elsif user.allowed_in_any_project?(:select_project_custom_fields) || user.allowed_globally?(:add_project)
|
||||
where(admin_only: false)
|
||||
|
||||
@@ -34,7 +34,7 @@ module ProjectCustomFields::Scopes
|
||||
|
||||
class_methods do
|
||||
def visible(user = User.current, project: nil)
|
||||
if user.admin?
|
||||
if user.active_admin?
|
||||
all
|
||||
elsif user.allowed_in_any_project?(:select_project_custom_fields) || user.allowed_globally?(:add_project)
|
||||
where(admin_only: false)
|
||||
|
||||
@@ -40,7 +40,7 @@ module Projects::Scopes
|
||||
def visible(user = User.current)
|
||||
# Use a shortcut for admins and anonymous where
|
||||
# we don't need to calculate for work package roles which is more expensive
|
||||
if user.admin? || user.anonymous?
|
||||
if user.active_admin? || user.anonymous?
|
||||
allowed_to(user, :view_project)
|
||||
else
|
||||
active.public_projects.or(active.where(id: user.members.select(:project_id)))
|
||||
|
||||
@@ -34,7 +34,7 @@ module UserCustomFields::Scopes
|
||||
|
||||
class_methods do
|
||||
def visible(user = User.current)
|
||||
if user.admin?
|
||||
if user.active_admin?
|
||||
all
|
||||
else
|
||||
where(admin_only: false)
|
||||
|
||||
@@ -61,9 +61,13 @@ class Budget < ApplicationRecord
|
||||
|
||||
class << self
|
||||
def visible(user = User.current)
|
||||
includes(:project)
|
||||
.references(:projects)
|
||||
.merge(Project.allowed_to(user, :view_budgets))
|
||||
if user.active_admin?
|
||||
all
|
||||
else
|
||||
includes(:project)
|
||||
.references(:projects)
|
||||
.merge(Project.allowed_to(user, :view_budgets))
|
||||
end
|
||||
end
|
||||
|
||||
# TODO: Extract into copy service
|
||||
|
||||
Reference in New Issue
Block a user