notification scaffold
This commit is contained in:
parent
5f14a6bcf8
commit
d55ade1686
10 changed files with 119 additions and 7 deletions
|
@ -54,13 +54,6 @@ class User < ActiveRecord::Base
|
|||
attr_accessible :login
|
||||
|
||||
|
||||
#
|
||||
# Notification levels
|
||||
#
|
||||
N_DISABLED = 0
|
||||
N_PARTICIPATING = 1
|
||||
N_WATCH = 2
|
||||
|
||||
#
|
||||
# Relations
|
||||
#
|
||||
|
@ -116,6 +109,9 @@ class User < ActiveRecord::Base
|
|||
format: { with: Gitlab::Regex.username_regex,
|
||||
message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" }
|
||||
|
||||
validates :notification_level,
|
||||
inclusion: { in: Notification.notification_levels },
|
||||
presence: true
|
||||
|
||||
validate :namespace_uniq, if: ->(user) { user.username_changed? }
|
||||
|
||||
|
@ -216,6 +212,10 @@ class User < ActiveRecord::Base
|
|||
username
|
||||
end
|
||||
|
||||
def notification
|
||||
@notification ||= Notification.new(self)
|
||||
end
|
||||
|
||||
def generate_password
|
||||
if self.force_random_password
|
||||
self.password = self.password_confirmation = Devise.friendly_token.first(8)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue