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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/packages/debian/publication.rb')
-rw-r--r--app/models/packages/debian/publication.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/app/models/packages/debian/publication.rb b/app/models/packages/debian/publication.rb
new file mode 100644
index 00000000000..93f5aa11d81
--- /dev/null
+++ b/app/models/packages/debian/publication.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class Packages::Debian::Publication < ApplicationRecord
+ belongs_to :package,
+ -> { where(package_type: :debian).where.not(version: nil) },
+ inverse_of: :debian_publication,
+ class_name: 'Packages::Package'
+ belongs_to :distribution,
+ inverse_of: :publications,
+ class_name: 'Packages::Debian::ProjectDistribution',
+ foreign_key: :distribution_id
+
+ validates :package, presence: true
+ validate :valid_debian_package_type
+
+ validates :distribution, presence: true
+
+ private
+
+ def valid_debian_package_type
+ return errors.add(:package, _('type must be Debian')) unless package&.debian?
+ return errors.add(:package, _('must be a Debian package')) unless package.debian_package?
+ end
+end