BigW Consortium Gitlab

lfs_object.rb 493 Bytes
Newer Older
1 2 3 4 5 6 7
class LfsObject < ActiveRecord::Base
  has_many :lfs_objects_projects, dependent: :destroy
  has_many :projects, through: :lfs_objects_projects

  validates :oid, presence: true, uniqueness: true

  mount_uploader :file, LfsObjectUploader
8 9 10

  def storage_project(project)
    if project && project.forked?
11
      storage_project(project.forked_from_project)
12 13 14 15
    else
      project
    end
  end
16 17 18 19

  def project_allowed_access?(project)
    projects.exists?(storage_project(project).id)
  end
20
end