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

Try moving the aac validation into the contracts

Dombi Attila03c4542161c6
diff --git a/app/contracts/groups/base_contract.rb b/app/contracts/groups/base_contract.rb
index ee0309e789d..540089dc77e 100644
--- a/app/contracts/groups/base_contract.rb
+++ b/app/contracts/groups/base_contract.rb
@@ -38,6 +38,9 @@ module Groups
validate :validate_unique_users
+ delegate :validate_custom_values, to: :model
+ validate :validate_custom_values
+
private
# Validating on the group_users since those are dealt with in the
diff --git a/app/contracts/projects/base_contract.rb b/app/contracts/projects/base_contract.rb
index a894a0e2ffe..f9343fa85cc 100644
--- a/app/contracts/projects/base_contract.rb
+++ b/app/contracts/projects/base_contract.rb
@@ -57,6 +57,9 @@ module Projects
validate :validate_user_allowed_to_manage
+ delegate :validate_custom_values, to: :model
+ validate :validate_custom_values
+
def assignable_parents
Project
.allowed_to(user, :add_subprojects)
diff --git a/app/contracts/users/base_contract.rb b/app/contracts/users/base_contract.rb
index 2dfb83fd0c6..ac509b515c3 100644
--- a/app/contracts/users/base_contract.rb
+++ b/app/contracts/users/base_contract.rb
@@ -62,6 +62,9 @@ module Users
delegate :available_custom_fields, to: :model
+ delegate :validate_custom_values, to: :model
+ validate :validate_custom_values
+
def reduce_writable_attributes(attributes)
super.tap do |writable|
writable << "password" if password_writable?
diff --git a/app/contracts/versions/base_contract.rb b/app/contracts/versions/base_contract.rb
index 96178fb42ba..4e28d414557 100644
--- a/app/contracts/versions/base_contract.rb
+++ b/app/contracts/versions/base_contract.rb
@@ -42,6 +42,9 @@ module Versions
validate :validate_project_is_set
validate :validate_sharing_included
+ delegate :validate_custom_values, to: :model
+ validate :validate_custom_values
+
attribute :name
attribute :description
attribute :start_date
diff --git a/app/contracts/work_packages/base_contract.rb b/app/contracts/work_packages/base_contract.rb
index a43c9ef9527..334de075fe5 100644
--- a/app/contracts/work_packages/base_contract.rb
+++ b/app/contracts/work_packages/base_contract.rb
@@ -154,6 +154,9 @@ module WorkPackages
validate :validate_duration_and_dates_are_not_derivable
+ delegate :validate_custom_values, to: :model
+ validate :validate_custom_values
+
def initialize(work_package, user, options: {})
super
diff --git a/lib_static/plugins/acts_as_customizable/lib/acts_as_customizable.rb b/lib_static/plugins/acts_as_customizable/lib/acts_as_customizable.rb
index e95c846b5b2..dcc6c0fbf1d 100644
--- a/lib_static/plugins/acts_as_customizable/lib/acts_as_customizable.rb
+++ b/lib_static/plugins/acts_as_customizable/lib/acts_as_customizable.rb
@@ -49,7 +49,7 @@ module Redmine
dependent: :delete_all,
validate: false,
autosave: true
- validate :validate_custom_values
+
send :include, Redmine::Acts::Customizable::InstanceMethods
before_save :ensure_custom_values_complete