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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-03-22 21:09:24 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-03-22 21:09:24 +0300
commit9a643ab892cfd7897fb7695bc158ce17ada81b1a (patch)
treefdd8b1bba4046b8829f97eecc56079b742fcb441 /app/models
parent06d4ce7ee0c0f9cf84a6799d97f64dd710d6e9f6 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r--app/models/user.rb2
-rw-r--r--app/models/users/in_product_marketing_email.rb28
2 files changed, 30 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index d37470db4c4..049c01256c1 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -199,6 +199,8 @@ class User < ApplicationRecord
has_many :reviews, foreign_key: :author_id, inverse_of: :author
+ has_many :in_product_marketing_emails, class_name: '::Users::InProductMarketingEmail'
+
#
# Validations
#
diff --git a/app/models/users/in_product_marketing_email.rb b/app/models/users/in_product_marketing_email.rb
new file mode 100644
index 00000000000..f43705dfb3d
--- /dev/null
+++ b/app/models/users/in_product_marketing_email.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+module Users
+ class InProductMarketingEmail < ApplicationRecord
+ include BulkInsertSafe
+
+ belongs_to :user
+
+ validates :user, presence: true
+ validates :track, presence: true
+ validates :series, presence: true
+ validates :user_id, uniqueness: {
+ scope: [:track, :series],
+ message: 'has already been sent'
+ }
+
+ enum track: {
+ create: 0,
+ verify: 1,
+ trial: 2,
+ team: 3
+ }, _suffix: true
+
+ scope :without_track_or_series, -> (track, series) do
+ where.not(track: track).or(where.not(series: series))
+ end
+ end
+end