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

[chore] add wp versions as attributes for subject generation

Eric Schubertf71c240a5ffb
diff --git a/app/models/types/pattern_resolver.rb b/app/models/types/pattern_resolver.rb
index 093bd740612..084a42ecbbb 100644
--- a/app/models/types/pattern_resolver.rb
+++ b/app/models/types/pattern_resolver.rb
@@ -56,16 +56,16 @@ module Types
attribute_token = @tokens.detect { |t| t.key == pattern_token.key }
return ATTRIBUTE_PLACEHOLDER if attribute_token.nil?
- stringify(attribute_token.call(context), nil_replacement(attribute_token))
+ I18n.with_locale(Setting.default_language) do
+ stringify(attribute_token.call(context), nil_replacement(attribute_token))
+ end
end
def nil_replacement(attribute_resolver)
- I18n.with_locale(Setting.default_language) do
- if attribute_resolver.context == :work_package
- "[#{attribute_resolver.label}]"
- else
- "[#{attribute_resolver.label_with_context}]"
- end
+ if attribute_resolver.context == :work_package
+ "[#{attribute_resolver.label}]"
+ else
+ "[#{attribute_resolver.label_with_context}]"
end
end
diff --git a/app/models/types/patterns/token_property_mapper.rb b/app/models/types/patterns/token_property_mapper.rb
index 9e3057a2969..e348f040ecf 100644
--- a/app/models/types/patterns/token_property_mapper.rb
+++ b/app/models/types/patterns/token_property_mapper.rb
@@ -54,16 +54,18 @@ module Types
AttributeToken.new(:parent_subject, -> { WorkPackage.human_attribute_name(:subject) }, ->(parent) { parent.subject }),
AttributeToken.new(:parent_status, -> { WorkPackage.human_attribute_name(:status) }, ->(parent) { parent.status&.name }),
AttributeToken.new(:parent_type, -> { WorkPackage.human_attribute_name(:type) }, ->(parent) { parent.type&.name }),
+ AttributeToken.new(:parent_version, -> { WorkPackage.human_attribute_name(:version) }, ->(parent) { parent.version&.name }),
AttributeToken.new(:priority, -> { WorkPackage.human_attribute_name(:priority) }, ->(wp) { wp.priority }),
AttributeToken.new(:project_id, -> { Project.human_attribute_name(:id) }, ->(project) { project.id }),
AttributeToken.new(:project_active, -> { Project.human_attribute_name(:active) }, ->(project) { project.active? }),
AttributeToken.new(:project_name, -> { Project.human_attribute_name(:name) }, ->(project) { project.name }),
- AttributeToken.new(:project_status, -> { Project.human_attribute_name(:status_code) }, ->(project) { project.status_code }),
+ AttributeToken.new(:project_status, -> { Project.human_attribute_name(:status_code) }, ->(project) { project.status_code.nil? ? nil : I18n.t("activerecord.attributes.project.status_codes.#{project.status_code}") }),
AttributeToken.new(:project_parent, -> { Project.human_attribute_name(:parent) }, ->(project) { project.parent_id }),
AttributeToken.new(:project_public, -> { Project.human_attribute_name(:public) }, ->(project) { project.public? }),
AttributeToken.new(:start_date, -> { WorkPackage.human_attribute_name(:start_date) }, ->(wp) { wp.start_date }),
AttributeToken.new(:status, -> { WorkPackage.human_attribute_name(:status) }, ->(wp) { wp.status&.name }),
- AttributeToken.new(:type, -> { WorkPackage.human_attribute_name(:type) }, ->(wp) { wp.type&.name })
+ AttributeToken.new(:type, -> { WorkPackage.human_attribute_name(:type) }, ->(wp) { wp.type&.name }),
+ AttributeToken.new(:version, -> { WorkPackage.human_attribute_name(:version) }, ->(wp) { wp.version&.name })
].freeze
# rubocop:enable Layout/LineLength