X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/2eb88069ea1a778e2a748e4d05244d31912398fa..aba81749d2477043232b82300c0ce15548b61888:/services/api/app/models/group.rb diff --git a/services/api/app/models/group.rb b/services/api/app/models/group.rb index 81161e24da..5c0aeba589 100644 --- a/services/api/app/models/group.rb +++ b/services/api/app/models/group.rb @@ -4,6 +4,7 @@ require 'can_be_an_owner' require 'trashable' +require 'update_priorities' class Group < ArvadosModel include HasUuid @@ -48,12 +49,19 @@ class Group < ArvadosModel t.add :can_manage end + # check if admins are allowed to make changes to the project, e.g. it + # isn't trashed or frozen. + def admin_change_permitted + !(FrozenGroup.where(uuid: self.uuid).any? || TrashedGroup.where(group_uuid: self.uuid).any?) + end + protected def self.attributes_required_columns super.merge( 'can_write' => ['owner_uuid', 'uuid'], 'can_manage' => ['owner_uuid', 'uuid'], + 'writable_by' => ['owner_uuid', 'uuid'], ) end @@ -177,6 +185,13 @@ class Group < ArvadosModel "select target_uuid as group_uuid, trash_at from #{temptable} where trash_at is not NULL " + "on conflict (group_uuid) do update set trash_at=EXCLUDED.trash_at", "Group.update_trash.insert") + ActiveRecord::Base.connection.exec_query( + "select container_uuid from container_requests where " + + "owner_uuid in (select target_uuid from #{temptable}) and " + + "requesting_container_uuid is NULL and state = 'Committed' and container_uuid is not NULL", + "Group.update_trash.update_priorities").each do |container_uuid| + update_priorities container_uuid["container_uuid"] + end end def update_frozen @@ -272,7 +287,7 @@ class Group < ArvadosModel if !super return false elsif group_class == "role" && - !Rails.configuration.Users.CreateRoleGroups && + !Rails.configuration.Users.CanCreateRoleGroups && !current_user.andand.is_admin raise PermissionDeniedError.new("this cluster does not allow users to create role groups") else