Welcome to mirror list, hosted at ThFree Co, Russian Federation.

metadatum.rb « pypi « packages « models « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ff247fedb59d6b7b4f3c65809aa4c525abba7c7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 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
  validates :required_python, length: { maximum: 255 }, allow_nil: false

  validate :pypi_package_type

  private

  def pypi_package_type
    unless package&.pypi?
      errors.add(:base, _('Package type must be PyPi'))
    end
  end
end