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
Allow writable attributes when a project is being archived.
Dombi Attila69a4e6dc2b18
diff --git a/app/contracts/projects/update_contract.rb b/app/contracts/projects/update_contract.rbindex cf156ea65ad..7a95732cf7a 100644--- a/app/contracts/projects/update_contract.rb+++ b/app/contracts/projects/update_contract.rb@@ -29,40 +29,44 @@module Projectsclass UpdateContract < BaseContractdef writable_attributes- permissions = {- project_attributes_only: options[:project_attributes_only],- edit_project: user.allowed_in_project?(:edit_project, model),- edit_project_attributes: user.allowed_in_project?(:edit_project_attributes, model)- }-- case permissions- in { project_attributes_only: true, edit_project_attributes: true } |- { edit_project: false, edit_project_attributes: true }+ if allow_project_attributes_onlywith_custom_fields_only(super)- in { project_attributes_only: true, edit_project_attributes: false } |- { edit_project: false, edit_project_attributes: false }- []- in { project_attributes_only: false, edit_project: true, edit_project_attributes: false }+ elsif allow_edit_attributes_onlywithout_custom_fields(super)- else+ elsif allow_all_attributessuper+ else+ []endendprivate- def without_custom_fields(changes)- changes.grep_v(/^custom_field_/)+ def project_attributes_only = options[:project_attributes_only].present?++ def edit_project = user.allowed_in_project?(:edit_project, model)++ def edit_project_attributes = user.allowed_in_project?(:edit_project_attributes, model)++ def allow_edit_attributes_only = edit_project && !project_attributes_only && !edit_project_attributes++ def allow_project_attributes_only+ edit_project_attributes && (project_attributes_only || !edit_project)end- def with_custom_fields_only(changes)- changes.grep(/^custom_field_/)+ def allow_all_attributes+ (edit_project && edit_project_attributes && !project_attributes_only) ||+ (changed_by_user == ["active"]) # Allow archiving, permission checked in manage_permissionend+ def without_custom_fields(changes) = changes.grep_v(/^custom_field_/)++ def with_custom_fields_only(changes) = changes.grep(/^custom_field_/)+def manage_permissionif changed_by_user == ["active"]:archive_project- elsif options[:project_attributes_only]+ elsif project_attributes_only:edit_project_attributeselse# if "active" is changed, :archive_project permission will also be