2020-10-27 00:50:13 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-05-15 06:29:01 +08:00
|
|
|
#
|
|
|
|
# Copyright (C) 2018 - present Instructure, Inc.
|
|
|
|
#
|
|
|
|
# This file is part of Canvas.
|
|
|
|
#
|
|
|
|
# Canvas is free software: you can redistribute it and/or modify it under
|
|
|
|
# the terms of the GNU Affero General Public License as published by the Free
|
|
|
|
# Software Foundation, version 3 of the License.
|
|
|
|
#
|
|
|
|
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
|
|
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
|
|
# details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License along
|
|
|
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
|
|
|
module LockedFor
|
2024-05-10 05:44:54 +08:00
|
|
|
MODULE_ATTRIBUTES = %w[id name context_type context_id workflow_state unlock_at].freeze
|
|
|
|
|
2018-05-15 06:29:01 +08:00
|
|
|
def locked_for?(user, opts = {})
|
|
|
|
lock_info = low_level_locked_for?(user, opts).dup
|
|
|
|
return false if lock_info == false
|
|
|
|
|
|
|
|
lock_info[:asset_string] = lock_info.delete(:object).asset_string
|
2024-05-10 05:44:54 +08:00
|
|
|
lock_info[:context_module] = lock_info.delete(:module).attributes.slice(*MODULE_ATTRIBUTES) if lock_info.key?(:module)
|
2018-05-15 06:29:01 +08:00
|
|
|
lock_info
|
|
|
|
end
|
|
|
|
end
|