Fix draft creation [SCI-8075]

This commit is contained in:
Anton 2023-03-03 15:36:43 +01:00
parent d1f26e1c7b
commit b4b5b70331

View file

@ -586,12 +586,13 @@ class Protocol < ApplicationRecord
end
def save_as_draft(current_user)
version = (latest_published_version || self).version_number + 1
parent_protocol = parent || self
version = (parent_protocol.latest_published_version || self).version_number + 1
draft = dup
draft.version_number = version
draft.protocol_type = :in_repository_draft
draft.parent = (parent || self)
draft.parent = parent_protocol
draft.published_by = nil
draft.published_on = nil
draft.version_comment = nil