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:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-03-28 14:41:00 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-03-30 11:44:20 +0300
commit31b0e53015e38e51d9c02cca85c9279600b1bf85 (patch)
tree2b0e9dcdb9ba11099b13fc790677bb59052d47fc /app/models/notification_setting.rb
parenta9346cab20f7e54a849877e2aa8601b8b3707652 (diff)
Introduce NotificationSetting model
It will hold notification setting per group or per project. It will allow get rid of notification level stored in Member model Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/models/notification_setting.rb')
-rw-r--r--app/models/notification_setting.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/models/notification_setting.rb b/app/models/notification_setting.rb
new file mode 100644
index 00000000000..0dce146b7a9
--- /dev/null
+++ b/app/models/notification_setting.rb
@@ -0,0 +1,14 @@
+class NotificationSetting < ActiveRecord::Base
+ belongs_to :user
+ belongs_to :source, polymorphic: true
+
+ validates :user, presence: true
+ validates :source, presence: true
+ validates :level, presence: true
+ validates :user_id, uniqueness: { scope: [:source_type, :source_id],
+ message: "already exists in source",
+ allow_nil: true }
+ # Notification level
+ # Note: When adding an option, it MUST go on the end of the array.
+ enum level: [:disabled, :participating, :watch, :global, :mention]
+end