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

refactor call

as-op9831be871999
diff --git a/app/models/work_package/exports/macros/attributes.rb b/app/models/work_package/exports/macros/attributes.rb
index 8c73907f0f4..b9636f46d5d 100644
--- a/app/models/work_package/exports/macros/attributes.rb
+++ b/app/models/work_package/exports/macros/attributes.rb
@@ -102,11 +102,22 @@ module WorkPackage::Exports
end
def self.resolve_label(model, attribute)
- model.human_attribute_name(
- ::API::Utilities::PropertyNameConverter.to_ar_name(attribute.to_sym, context: model.new)
- )
+ model.human_attribute_name(to_ar_name(attribute, model.new))
end
+ def self.to_ar_name(attribute, context)
+ ::API::Utilities::PropertyNameConverter.to_ar_name(attribute.to_sym, context:)
+ end
+
+ ##
+ # Resolves a work package or project match based on the type and id.
+ # Returns the formatted value or an error message if not found.
+ #
+ # @param id [String] The ID of the work package or project.
+ # @param type [String] The type of the match (label or value).
+ # @param attribute [String] The attribute to resolve.
+ # @param user [User] The user context for visibility checks.
+
def self.resolve_work_package_match(id, type, attribute, user)
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"
@@ -162,7 +173,7 @@ module WorkPackage::Exports
def self.convert_to_attribute_name(custom_field, attribute, obj)
if custom_field.nil?
- ::API::Utilities::PropertyNameConverter.to_ar_name(attribute.to_sym, context: obj)
+ to_ar_name(attribute, obj)
else
"cf_#{custom_field.id}"
end