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

simplify wp access check & find https://github.com/opf/openproject/pull/15702#discussion_r1627409100

as-op076b56073bcf
diff --git a/app/models/work_package/exports/macros/attributes.rb b/app/models/work_package/exports/macros/attributes.rb
index a2867942c59..99e8631ef42 100644
--- a/app/models/work_package/exports/macros/attributes.rb
+++ b/app/models/work_package/exports/macros/attributes.rb
@@ -101,9 +101,8 @@ module WorkPackage::Exports
return resolve_label_work_package(attribute) if type == "label"
return msg_macro_error(I18n.t('export.macro.model_not_found', model: type)) unless type == "value"
- work_package = WorkPackage.find_by(id:)
- if work_package.nil? ||
- !user.allowed_in_work_package?(:view_work_packages, work_package)
+ work_package = WorkPackage.visible(user).find_by(id:)
+ if work_package.nil?
return msg_macro_error(I18n.t('export.macro.resource_not_found', resource: "#{WorkPackage.name} #{id}"))
end