mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-07 05:34:55 +08:00
Preserve old protocol types for backward compatibility, fix protocol draft user permissions [SCI-8083] (#5123)
This commit is contained in:
parent
fcfe8d81cb
commit
d285a0a9db
3 changed files with 20 additions and 9 deletions
|
@ -27,9 +27,12 @@ class Protocol < ApplicationRecord
|
|||
enum protocol_type: {
|
||||
unlinked: 0,
|
||||
linked: 1,
|
||||
in_repository_published_original: 2,
|
||||
in_repository_draft: 3,
|
||||
in_repository_published_version: 4
|
||||
in_repository_private: 2, # Deprecated
|
||||
in_repository_public: 3, # Deprecated
|
||||
in_repository_archived: 4, # Deprecated
|
||||
in_repository_published_original: 5,
|
||||
in_repository_draft: 6,
|
||||
in_repository_published_version: 7
|
||||
}
|
||||
|
||||
auto_strip_attributes :name, :description, nullify: false
|
||||
|
|
|
@ -140,7 +140,7 @@ module PermissionExtends
|
|||
TeamPermissions::LABEL_TEMPLATES_MANAGE,
|
||||
ProtocolPermissions::READ,
|
||||
ProtocolPermissions::READ_ARCHIVED,
|
||||
ProtocolPermissions::MANAGE,
|
||||
ProtocolPermissions::MANAGE_DRAFT,
|
||||
ReportPermissions::READ,
|
||||
ReportPermissions::MANAGE,
|
||||
ProjectPermissions::READ,
|
||||
|
|
|
@ -14,13 +14,13 @@ class AddProtocolVersioning < ActiveRecord::Migration[6.1]
|
|||
end
|
||||
|
||||
execute(
|
||||
'UPDATE "protocols" SET "protocol_type" = 3, "archived" = TRUE WHERE "protocols"."protocol_type" = 4;'
|
||||
'UPDATE "protocols" SET "protocol_type" = 6, "archived" = TRUE WHERE "protocols"."protocol_type" = 4;'
|
||||
)
|
||||
execute(
|
||||
'UPDATE "protocols" SET "visibility" = 1 WHERE "protocols"."protocol_type" = 3;'
|
||||
)
|
||||
execute(
|
||||
'UPDATE "protocols" SET "protocol_type" = 2 ' \
|
||||
'UPDATE "protocols" SET "protocol_type" = 5 ' \
|
||||
'WHERE "id" IN (' \
|
||||
'SELECT DISTINCT "protocols"."id" FROM "protocols" ' \
|
||||
'JOIN "protocols" "linked_children" ON "linked_children"."parent_id" = "protocols"."id" ' \
|
||||
|
@ -28,7 +28,7 @@ class AddProtocolVersioning < ActiveRecord::Migration[6.1]
|
|||
');'
|
||||
)
|
||||
execute(
|
||||
'UPDATE "protocols" SET "protocol_type" = 3 ' \
|
||||
'UPDATE "protocols" SET "protocol_type" = 6 ' \
|
||||
'WHERE "id" IN (' \
|
||||
'SELECT DISTINCT "protocols"."id" FROM "protocols" ' \
|
||||
'LEFT OUTER JOIN "protocols" "linked_children" ON "linked_children"."parent_id" = "protocols"."id" ' \
|
||||
|
@ -37,16 +37,24 @@ class AddProtocolVersioning < ActiveRecord::Migration[6.1]
|
|||
)
|
||||
execute(
|
||||
'UPDATE "protocols" SET "published_on" = "created_at", "published_by_id" = "added_by_id" ' \
|
||||
'WHERE "protocols"."protocol_type" = 2 ' \
|
||||
'WHERE "protocols"."protocol_type" = 5 ' \
|
||||
'AND "protocols"."published_on" IS NULL;'
|
||||
)
|
||||
end
|
||||
|
||||
def down
|
||||
execute(
|
||||
'UPDATE "protocols" SET "protocol_type" = 4 WHERE "protocols"."protocol_type" IN (2, 3, 4) AND ' \
|
||||
'UPDATE "protocols" SET "protocol_type" = 4 WHERE "protocols"."protocol_type" IN (5, 6, 7) AND ' \
|
||||
'"protocols"."archived" = TRUE;'
|
||||
)
|
||||
execute(
|
||||
'UPDATE "protocols" SET "protocol_type" = 3 WHERE "protocols"."protocol_type" IN (5, 6, 7) AND ' \
|
||||
'"protocols"."visibility" = 1;'
|
||||
)
|
||||
execute(
|
||||
'UPDATE "protocols" SET "protocol_type" = 2 WHERE "protocols"."protocol_type" IN (5, 6, 7) AND ' \
|
||||
'"protocols"."visibility" != 1;'
|
||||
)
|
||||
change_table :protocols, bulk: true do |t|
|
||||
t.remove_references :published_by
|
||||
t.remove_references :last_modified_by
|
||||
|
|
Loading…
Add table
Reference in a new issue