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
[#65401] Project phase field shows in pdf report even when it doesn't show on wp
as-op10994f8af980
diff --git a/app/models/work_package/exports/attributes.rb b/app/models/work_package/exports/attributes.rbnew file mode 100644index 00000000000..08497bfe4d9--- /dev/null+++ b/app/models/work_package/exports/attributes.rb@@ -0,0 +1,38 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#+++module WorkPackage::Exports+ module Attributes+ def user_allowed_in_view_attribute?(obj, attribute_name)+ if attribute_name.to_sym == :project_phase && obj.is_a?(WorkPackage)+ User.current.allowed_in_project?(:view_project_phases, obj.project)+ else+ true+ end+ end+ end+enddiff --git a/app/models/work_package/exports/macros/attributes.rb b/app/models/work_package/exports/macros/attributes.rbindex 71f7947b3d4..2d4b0d4d67c 100644--- a/app/models/work_package/exports/macros/attributes.rb+++ b/app/models/work_package/exports/macros/attributes.rb@@ -45,6 +45,7 @@ module WorkPackage::Exports# projectValue:1234:active # Outputs project with id 1234 value for "active"# projectValue:my-project-identifier:active # Outputs project with identifier my-project-identifier value for "active"class Attributes < OpenProject::TextFormatting::Matchers::RegexMatcher+ extend WorkPackage::Exports::AttributesDISABLED_PROJECT_RICH_TEXT_FIELDS = %i[description status_explanation status_description].freezeDISABLED_WORK_PACKAGE_RICH_TEXT_FIELDS = %i[description].freeze@@ -154,6 +155,8 @@ module WorkPackage::Exportselse"cf_#{cf.id}"end++ return "" if cf.nil? && !user_allowed_in_view_attribute?(obj, ar_name)return msg_macro_error_rich_text if disabled_rich_text_fields.include?(ar_name.to_sym)format_attribute_value(ar_name, obj.class, obj)diff --git a/app/models/work_package/pdf_export/export/wp/attributes.rb b/app/models/work_package/pdf_export/export/wp/attributes.rbindex bb41a95233f..445b4eb7961 100644--- a/app/models/work_package/pdf_export/export/wp/attributes.rb+++ b/app/models/work_package/pdf_export/export/wp/attributes.rb@@ -29,6 +29,8 @@#++module WorkPackage::PDFExport::Export::Wp::Attributes+ include WorkPackage::Exports::Attributes+def write_attributes!(work_package)work_package.type.attribute_groups@@ -138,6 +140,10 @@ module WorkPackage::PDFExport::Export::Wp::Attributescurrent_part = { type: :attribute, list: [] }parts = [current_part]group.attributes.each do |form_key|+ if !CustomField.custom_field_attribute?(form_key) && !user_allowed_in_view_attribute?(work_package, form_key)+ next+ end+if allowed_long_text_custom_field?(form_key, work_package)cf = form_key_to_custom_field(form_key)if current_part[:type] == :long_text