diff --git a/app/controllers/protocols_controller.rb b/app/controllers/protocols_controller.rb index b0ade7fb4..63a782d59 100644 --- a/app/controllers/protocols_controller.rb +++ b/app/controllers/protocols_controller.rb @@ -909,7 +909,6 @@ class ProtocolsController < ApplicationController end def set_inline_name_editing - return unless @protocol.initial_draft? return unless can_manage_protocol_draft_in_repository?(@protocol) @inline_editable_title_config = { diff --git a/app/models/protocol.rb b/app/models/protocol.rb index 061801c69..e16f385b0 100644 --- a/app/models/protocol.rb +++ b/app/models/protocol.rb @@ -70,27 +70,10 @@ class Protocol < ApplicationRecord with_options if: :in_repository_published_version? do validates :parent, presence: true validate :parent_type_constraint - validate :versions_same_name_constraint end with_options if: :in_repository_draft? do # Only one draft can exist for each protocol validate :ensure_single_draft - validate :versions_same_name_constraint - end - with_options if: -> { in_repository? && !parent && !archived_changed?(from: false) } do |protocol| - # Active protocol must have unique name inside its team - protocol - .validates_uniqueness_of :name, case_sensitive: false, - scope: :team, - conditions: lambda { - where( - protocol_type: [ - Protocol.protocol_types[:in_repository_published_original], - Protocol.protocol_types[:in_repository_draft] - ], - parent_id: nil - ) - } end with_options if: -> { in_repository? && archived? && !previous_version } do |protocol| protocol.validates :archived_by, presence: true @@ -796,12 +779,6 @@ class Protocol < ApplicationRecord end end - def versions_same_name_constraint - if parent.present? && !parent.name.eql?(name) - errors.add(:base, I18n.t('activerecord.errors.models.protocol.wrong_version_name')) - end - end - def version_number_constraint if Protocol.where(protocol_type: Protocol::REPOSITORY_TYPES) .where.not(id: id) diff --git a/config/locales/en.yml b/config/locales/en.yml index 62f4a64ee..17ecd6671 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -164,7 +164,6 @@ en: protocol: unchangable: "Published protocols can not be changed!" wrong_parent_type: "Protocol can only be linked to published protocol!" - wrong_version_name: "Protocol versions should have same name!" wrong_version_number: "Protocol version number should be sequential!" wrong_parent_draft_number: "Procol can have only 1 draft" attributes: