mirror of
https://gitlab.com/gitlab-org/gitlab-foss.git
synced 2025-08-01 16:04:19 +00:00
22 lines
522 B
Ruby
22 lines
522 B
Ruby
# frozen_string_literal: true
|
|
|
|
class LfsFileLock < ApplicationRecord
|
|
belongs_to :project
|
|
belongs_to :user
|
|
|
|
scope :for_paths, ->(paths) { where(path: paths) }
|
|
scope :not_for_users, ->(user_ids) { where.not(user_id: user_ids) }
|
|
|
|
validates :project_id, :user_id, :path, presence: true
|
|
|
|
def self.for_path!(path)
|
|
find_by!(path: path)
|
|
end
|
|
|
|
def can_be_unlocked_by?(current_user, forced = false)
|
|
return true if current_user.id == user_id
|
|
|
|
forced && current_user.can?(:admin_project, project)
|
|
end
|
|
end
|