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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
extract I18n strings, adjust specs, test for excluded replacements e.g. markdown/html code blocks
as-ope40050c19040
diff --git a/app/models/work_package/exports/macros/attributes.rb b/app/models/work_package/exports/macros/attributes.rbindex 6ce70aee38a..2fcc46d4be1 100644--- a/app/models/work_package/exports/macros/attributes.rb+++ b/app/models/work_package/exports/macros/attributes.rb@@ -67,10 +67,22 @@ module WorkPackage::Exportselsif model_s == "project"resolve_project_match(id || work_package.project.id, type, attribute, user)else- "[Error: Invalid attribute macro: #{model_s}]"+ msg_macro_error I18n.t('export.macro.model_not_found', model: model_s)endend+ def self.msg_macro_error(message)+ msg_inline I18n.t('export.macro.error', message:)+ end++ def self.msg_macro_error_rich_text+ msg_inline I18n.t('export.macro.rich_text_unsupported')+ end++ def self.msg_inline(message)+ "[#{message}]"+ end+def self.resolve_label_work_package(attribute)resolve_label(WorkPackage, attribute)end@@ -87,11 +99,11 @@ module WorkPackage::Exportsdef self.resolve_work_package_match(id, type, attribute, user)return resolve_label_work_package(attribute) if type == "label"- return "[Error: Invalid attribute macro: #{type}]" unless type == "value"+ 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_project?(:view_work_packages, work_package.project)- return "[Error: #{WorkPackage.name} #{id} not found}]"+ return msg_macro_error(I18n.t('export.macro.resource_not_found', resource: "#{WorkPackage.name} #{id}"))endresolve_value_work_package(work_package, attribute)@@ -99,11 +111,11 @@ module WorkPackage::Exportsdef self.resolve_project_match(id, type, attribute, user)return resolve_label_project(attribute) if type == "label"- return "[Error: Invalid attribute macro: #{type}]" unless type == "value"+ return msg_macro_error(I18n.t("export.macro.model_not_found", model: type)) unless type == "value"project = Project.find_by(id:)if project.nil? || !user.allowed_in_project?(:view_project, project)- return "[Error: #{Project.name} #{id} not found}]"+ return msg_macro_error(I18n.t("export.macro.resource_not_found", resource: "#{Project.name} #{id}"))endresolve_value_project(project, attribute)@@ -121,14 +133,14 @@ module WorkPackage::Exportselsear_name = "cf_#{cf.id}"# currently we do not support embedding rich text fields: long text custom fields- return "[Rich text embedding currently not supported in export]" if cf.formattable?+ return msg_macro_error_rich_text if cf.formattable?# TODO: Is the user allowed to see this custom field/"project attribute"?end# currently we do not support embedding rich text field: e.g. projectValue:1234:descriptionif DISABLED_PROJECT_RICH_TEXT_FIELDS.include?(ar_name.to_sym)- return "[Rich text embedding currently not supported in export]"+ return msg_macro_error_rich_textend@@ -142,14 +154,14 @@ module WorkPackage::Exportselsear_name = "cf_#{cf.id}"# currently we do not support embedding rich text fields: long text custom fields- return "[Rich text embedding currently not supported in export]" if cf.formattable?+ return msg_macro_error_rich_text if cf.formattable?# TODO: Are there access restrictions on work_package custom fields?end# currently we do not support embedding rich text field: workPackageValue:1234:descriptionif DISABLED_WORK_PACKAGE_RICH_TEXT_FIELDS.include?(ar_name.to_sym)- return "[Rich text embedding currently not supported in export]"+ return msg_macro_error_rich_textenddiff --git a/config/locales/en.yml b/config/locales/en.ymlindex 5c221a64da4..5b079c47a57 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -1705,6 +1705,12 @@ Project attributes and sections are defined in the <a href=%{admin_settings_url}pdf_gantt: "PDF Gantt"image:omitted: "Image not exported."+ macro:+ error: "Macro error: %{message}"+ attribute_not_found: "Attribute not found: %{attribute}"+ model_not_found: "Invalid attribute model: %{model}"+ resource_not_found: "Invalid attribute model: %{resource}"+ rich_text_unsupported: "Rich text embedding currently not supported in export."units:hours: hdays: ddiff --git a/spec/models/work_packages/pdf_export/work_package_to_pdf_spec.rb b/spec/models/work_packages/pdf_export/work_package_to_pdf_spec.rbindex 4491fbbd77e..82f89de5e77 100644--- a/spec/models/work_packages/pdf_export/work_package_to_pdf_spec.rb+++ b/spec/models/work_packages/pdf_export/work_package_to_pdf_spec.rb@@ -206,17 +206,17 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageToPdf do["status", status.name],["subject", "Work package 1"],["type", type.name],- ["description", "[Rich text embedding currently not supported in export]"]+ ["description", "[#{I18n.t('export.macro.rich_text_unsupported')}]"]]endlet(:supported_project_embeds) do[["active", "Yes"],- ["description", "[Rich text embedding currently not supported in export]"],+ ["description", "[#{I18n.t('export.macro.rich_text_unsupported')}]"],["identifier", project.identifier],["name", project.name],["status", I18n.t("activerecord.attributes.project.status_codes.#{project.status_code}")],- ["statusExplanation", "[Rich text embedding currently not supported in export]"],+ ["statusExplanation", "[#{I18n.t('export.macro.rich_text_unsupported')}]"],["parent", parent_project.name],["public", "Yes"]]@@ -229,7 +229,19 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageToPdf dolet(:description) do<<~DESCRIPTION## Work package attributes and labels- <table><tbody>#{supported_work_package_embeds_table}</tbody></table>+ <table><tbody>#{supported_work_package_embeds_table}+ <tr><td>No replacement of:</td><td>+ <code>workPackageValue:1:assignee</code>+ <code>workPackageLabel:assignee</code>+ </td></tr>+ </tbody></table>++ `workPackageValue:2:assignee workPackageLabel:assignee`++ ```+ workPackageValue:3:assignee+ workPackageLabel:assignee+ ```DESCRIPTIONendlet(:supported_project_embeds_table) do@@ -256,7 +268,10 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageToPdf doAPI::Utilities::PropertyNameConverter.to_ar_name(embed[0].to_sym, context: work_package)), embed[1]]end,+ "No replacement of:", "workPackageValue:1:assignee", " ", "workPackageLabel:assignee",+ "workPackageValue:2:assignee workPackageLabel:assignee","1", export_time_formatted, project.name,+ "workPackageValue:3:assignee", "workPackageLabel:assignee","LongText","Project attributes and labels",supported_project_embeds.map do |embed|