debian-mirror-gitlab/app/models/packages/pypi/metadatum.rb

21 lines
482 B
Ruby
Raw Normal View History

2020-07-28 23:09:34 +05:30
# frozen_string_literal: true
class Packages::Pypi::Metadatum < ApplicationRecord
self.primary_key = :package_id
belongs_to :package, -> { where(package_type: :pypi) }, inverse_of: :pypi_metadatum
validates :package, presence: true
2020-11-24 15:15:51 +05:30
validates :required_python, length: { maximum: 255 }, allow_blank: true
2020-07-28 23:09:34 +05:30
validate :pypi_package_type
private
def pypi_package_type
unless package&.pypi?
errors.add(:base, _('Package type must be PyPi'))
end
end
end