Merge pull request #7222 from opf/fix/30053/correct-writable-test

[30053] Fix writable scope check

[ci skip]
pull/7226/head
Oliver Günther 6 years ago committed by GitHub
commit 34fedd8cd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      modules/boards/lib/open_project/boards/grid_registration.rb
  2. 6
      modules/grids/lib/grids/configuration.rb
  3. 4
      modules/grids/lib/grids/configuration/registration.rb

@ -23,13 +23,27 @@ module OpenProject
nil
end
def writable_scopes
manage_allowed = Project.allowed_to(User.current, :manage_board_views)
board_projects = Project.where(id: manage_allowed)
board_projects.map { |p| url_helpers.project_work_package_boards_path(p) }
end
##
# Determines whether the given scope is writable by the current user
def writable_scope?(scope)
writable_scopes.include? scope
end
def all_scopes
view_allowed = Project.allowed_to(User.current, :show_board_views)
manage_allowed = Project.allowed_to(User.current, :manage_board_views)
board_projects = Project
.where(id: view_allowed)
.or(Project.where(id: manage_allowed))
.where(id: view_allowed)
.or(Project.where(id: manage_allowed))
board_projects.map { |p| url_helpers.project_work_package_boards_path(p) }
end

@ -47,6 +47,10 @@ module Grids::Configuration
all.map(&:all_scopes).flatten.compact
end
def writable_scopes
all.map(&:writable_scopes).flatten.compact
end
def all
grid_register.values
end
@ -109,7 +113,7 @@ module Grids::Configuration
##
# Determines whether the given scope is writable by the current user
def writable_scope?(scope)
all_scopes.include? scope
writable_scopes.include? scope
end
##

@ -90,6 +90,10 @@ module Grids::Configuration
Array(url_helpers.send(@to_scope))
end
def writable_scopes
all_scopes
end
def visible(_user = User.current)
::Grids::Grid
.where(type: grid_class)

Loading…
Cancel
Save