2013-03-27 13:04:29 -04:00
|
|
|
class Notification
|
|
|
|
#
|
|
|
|
# Notification levels
|
|
|
|
#
|
|
|
|
N_DISABLED = 0
|
|
|
|
N_PARTICIPATING = 1
|
|
|
|
N_WATCH = 2
|
2013-04-04 15:11:51 -04:00
|
|
|
N_GLOBAL = 3
|
2014-12-29 08:55:21 -05:00
|
|
|
N_MENTION = 4
|
2013-03-27 13:04:29 -04:00
|
|
|
|
2013-04-04 15:11:51 -04:00
|
|
|
attr_accessor :target
|
2013-03-27 13:04:29 -04:00
|
|
|
|
2014-02-17 11:06:24 -05:00
|
|
|
class << self
|
|
|
|
def notification_levels
|
2015-09-14 20:27:54 -04:00
|
|
|
[N_DISABLED, N_MENTION, N_PARTICIPATING, N_WATCH]
|
2014-02-17 11:06:24 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def options_with_labels
|
|
|
|
{
|
|
|
|
disabled: N_DISABLED,
|
|
|
|
participating: N_PARTICIPATING,
|
|
|
|
watch: N_WATCH,
|
2014-12-29 08:55:21 -05:00
|
|
|
mention: N_MENTION,
|
2014-02-17 11:06:24 -05:00
|
|
|
global: N_GLOBAL
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def project_notification_levels
|
2015-09-16 20:46:24 -04:00
|
|
|
[N_DISABLED, N_MENTION, N_PARTICIPATING, N_WATCH, N_GLOBAL]
|
2014-02-17 11:06:24 -05:00
|
|
|
end
|
2013-04-04 15:11:51 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def initialize(target)
|
|
|
|
@target = target
|
2013-03-27 13:04:29 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def disabled?
|
2013-04-04 15:11:51 -04:00
|
|
|
target.notification_level == N_DISABLED
|
2013-03-27 13:04:29 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def participating?
|
2013-04-04 15:11:51 -04:00
|
|
|
target.notification_level == N_PARTICIPATING
|
2013-03-27 13:04:29 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def watch?
|
2013-04-04 15:11:51 -04:00
|
|
|
target.notification_level == N_WATCH
|
|
|
|
end
|
|
|
|
|
|
|
|
def global?
|
|
|
|
target.notification_level == N_GLOBAL
|
2013-03-27 13:04:29 -04:00
|
|
|
end
|
2014-02-17 11:06:24 -05:00
|
|
|
|
2014-12-29 08:55:21 -05:00
|
|
|
def mention?
|
|
|
|
target.notification_level == N_MENTION
|
|
|
|
end
|
|
|
|
|
2014-02-17 11:06:24 -05:00
|
|
|
def level
|
|
|
|
target.notification_level
|
|
|
|
end
|
2015-09-16 20:46:24 -04:00
|
|
|
|
|
|
|
def to_s
|
|
|
|
case level
|
|
|
|
when N_DISABLED
|
|
|
|
'Disabled'
|
|
|
|
when N_PARTICIPATING
|
|
|
|
'Participating'
|
|
|
|
when N_WATCH
|
|
|
|
'Watching'
|
|
|
|
when N_MENTION
|
|
|
|
'On mention'
|
|
|
|
when N_GLOBAL
|
|
|
|
'Global'
|
|
|
|
else
|
|
|
|
# do nothing
|
|
|
|
end
|
|
|
|
end
|
2013-03-27 13:04:29 -04:00
|
|
|
end
|