Merge pull request #8004 from andrej-scinote/aj_SCI_10851

Remove constraint for the protocol template name [SCI-10851]
This commit is contained in:
andrej-scinote 2024-10-30 09:07:17 +01:00 committed by GitHub
commit 004745d4e7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -75,21 +75,6 @@ class Protocol < ApplicationRecord
# Only one draft can exist for each protocol
validate :ensure_single_draft
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
protocol.validates :archived_on, presence: true