mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-25 00:03:27 +08:00
Merge pull request #5187 from artoscinote/ma_SCI_8182
Fix issues with protocol assignments and published attributes [SCI-8182]
This commit is contained in:
commit
5016034189
3 changed files with 21 additions and 3 deletions
|
@ -197,7 +197,11 @@ module Users
|
|||
protocol.restored_by = new_owner if protocol.restored_by == user_assignment.user
|
||||
protocol.save!(validate: false)
|
||||
protocol.user_assignments.find_by(user: new_owner)&.destroy!
|
||||
protocol.user_assignments.create!(user: new_owner, user_role: UserRole.find_predefined_owner_role)
|
||||
protocol.user_assignments.create!(
|
||||
user: new_owner,
|
||||
user_role: UserRole.find_predefined_owner_role,
|
||||
assigned: :manually
|
||||
)
|
||||
end
|
||||
|
||||
# Make new owner author of all inventory items that were added
|
||||
|
|
|
@ -14,7 +14,7 @@ class AddProtocolVersioning < ActiveRecord::Migration[6.1]
|
|||
end
|
||||
|
||||
execute(
|
||||
'UPDATE "protocols" SET "protocol_type" = 6, "archived" = TRUE WHERE "protocols"."protocol_type" = 4;'
|
||||
'UPDATE "protocols" SET "protocol_type" = 6, "archived" = TRUE, "published_on" = NULL WHERE "protocols"."protocol_type" = 4;'
|
||||
)
|
||||
execute(
|
||||
'UPDATE "protocols" SET "visibility" = 1 WHERE "protocols"."protocol_type" = 3;'
|
||||
|
@ -28,7 +28,7 @@ class AddProtocolVersioning < ActiveRecord::Migration[6.1]
|
|||
');'
|
||||
)
|
||||
execute(
|
||||
'UPDATE "protocols" SET "protocol_type" = 6 ' \
|
||||
'UPDATE "protocols" SET "protocol_type" = 6, "published_on" = NULL ' \
|
||||
'WHERE "id" IN (' \
|
||||
'SELECT DISTINCT "protocols"."id" FROM "protocols" ' \
|
||||
'LEFT OUTER JOIN "protocols" "linked_children" ON "linked_children"."parent_id" = "protocols"."id" ' \
|
||||
|
@ -40,6 +40,13 @@ class AddProtocolVersioning < ActiveRecord::Migration[6.1]
|
|||
'WHERE "protocols"."protocol_type" = 5 ' \
|
||||
'AND "protocols"."published_on" IS NULL;'
|
||||
)
|
||||
|
||||
execute(
|
||||
'UPDATE "protocols" SET "published_by_id" = "added_by_id" ' \
|
||||
'WHERE "protocols"."protocol_type" = 5 ' \
|
||||
'AND "protocols"."visibility" = 1' \
|
||||
'AND "protocols"."published_by_id" IS NULL;'
|
||||
)
|
||||
end
|
||||
|
||||
def down
|
||||
|
|
|
@ -23,6 +23,13 @@ class AddProtocolVersioningPermissions < ActiveRecord::Migration[6.1]
|
|||
@normal_user_role.permissions = @normal_user_role.permissions - REMOVED_NORMAL_USER_PERMISSIONS
|
||||
@owner_role.save(validate: false)
|
||||
@normal_user_role.save(validate: false)
|
||||
|
||||
# properly assign protocol owners, who must always be marked as assigned manually
|
||||
UserAssignment.where(
|
||||
assignable_type: 'Protocol',
|
||||
user_role: UserRole.find_predefined_owner_role,
|
||||
assigned: :automatically
|
||||
).update_all(assigned: :manually)
|
||||
end
|
||||
|
||||
dir.down do
|
||||
|
|
Loading…
Reference in a new issue