Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Only pull project permissions, when grid is bound to a project

Klaus Zanders7637f00059d6
diff --git a/modules/grids/app/representers/api/v3/grids/grid_representer.rb b/modules/grids/app/representers/api/v3/grids/grid_representer.rb
index c6695f8a5c7..07c3a36ee31 100644
--- a/modules/grids/app/representers/api/v3/grids/grid_representer.rb
+++ b/modules/grids/app/representers/api/v3/grids/grid_representer.rb
@@ -36,7 +36,7 @@ module API
include ::API::V3::Attachments::AttachableRepresenterMixin
cached_representer key_parts: %i(widgets),
- dependencies: -> { all_permissions_granted_to_user_under_project }
+ dependencies: -> { [User.current] + all_permissions_granted_to_user_under_project }
resource_link :scope,
getter: ->(*) {
@@ -167,13 +167,17 @@ module API
end
def all_permissions_granted_to_user_under_project
- Role
- .joins(:members)
- .where(members: { project_id: represented.project, principal: User.current })
- .map(&:permissions)
- .flatten
- .uniq
- .sort
+ scope = if represented.respond_to?(:project)
+ Role
+ .joins(:members)
+ .where(members: { project_id: represented.project, principal: User.current })
+ else
+ Role
+ .joins(:members)
+ .where(members: { principal: User.current, project: nil, entity: nil })
+ end
+
+ scope.map(&:permissions).flatten.uniq.sort
end
end
end