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

Rename project custom field project mappings contract validation methods.

Dombi Attila791155312bd1
diff --git a/app/contracts/project_custom_field_project_mappings/base_contract.rb b/app/contracts/project_custom_field_project_mappings/base_contract.rb
index 2e18e2beb56..106abf73b07 100644
--- a/app/contracts/project_custom_field_project_mappings/base_contract.rb
+++ b/app/contracts/project_custom_field_project_mappings/base_contract.rb
@@ -31,17 +31,17 @@ module ProjectCustomFieldProjectMappings
attribute :project_id
attribute :custom_field_id
- validate :validate_has_select_project_custom_fields_permission
- validate :validate_is_not_required
- validate :validate_is_visbile_to_user
+ validate :select_project_custom_fields_permission
+ validate :not_required
+ validate :visbile_to_user
- def validate_has_select_project_custom_fields_permission
+ def select_project_custom_fields_permission
return if user.allowed_in_project?(:select_project_custom_fields, model.project)
errors.add :base, :error_unauthorized
end
- def validate_is_not_required
+ def not_required
# only mappings of custom fields which are not required can be manipulated by the user
# enabling a custom field which is required happens in an after_save hook within the custom field model itself
return if model.project_custom_field.nil? || !model.project_custom_field.required?
@@ -49,7 +49,7 @@ module ProjectCustomFieldProjectMappings
errors.add :custom_field_id, :invalid
end
- def validate_is_visbile_to_user
+ def visbile_to_user
# "invisible" custom fields can only be seen and edited by admins
# using visible scope to check if the custom field is actually visible to the user
return if model.project_custom_field.nil? || ProjectCustomField.visible.pluck(:id).include?(model.project_custom_field.id)