2011-07-19 02:49:15 +04:00
|
|
|
from inspect import isclass
|
|
|
|
|
2011-11-19 08:52:25 +04:00
|
|
|
from amo.helpers import loc
|
2011-07-19 02:49:15 +04:00
|
|
|
from celery.datastructures import AttributeDict
|
|
|
|
from tower import ugettext_lazy as _
|
|
|
|
|
|
|
|
|
|
|
|
class _NOTIFICATION(object):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class thanks(_NOTIFICATION):
|
|
|
|
id = 2
|
|
|
|
group = 'user'
|
|
|
|
short = 'dev_thanks'
|
|
|
|
label = _('an add-on developer thanks me for a contribution')
|
|
|
|
mandatory = False
|
|
|
|
default_checked = True
|
|
|
|
|
|
|
|
|
|
|
|
class reply(_NOTIFICATION):
|
|
|
|
id = 3
|
|
|
|
group = 'user'
|
|
|
|
short = 'reply'
|
|
|
|
label = _('an add-on developer replies to my review')
|
|
|
|
mandatory = False
|
|
|
|
default_checked = True
|
|
|
|
|
|
|
|
|
2011-11-19 08:52:25 +04:00
|
|
|
class app_reply(reply):
|
|
|
|
app = True
|
|
|
|
label = loc('an app developer replies to my review')
|
|
|
|
|
|
|
|
|
2011-07-19 02:49:15 +04:00
|
|
|
class new_features(_NOTIFICATION):
|
|
|
|
id = 4
|
|
|
|
group = 'user'
|
|
|
|
short = 'new_features'
|
|
|
|
label = _('new add-ons or Firefox features are available')
|
|
|
|
mandatory = False
|
|
|
|
default_checked = True
|
|
|
|
|
|
|
|
|
|
|
|
class upgrade_success(_NOTIFICATION):
|
|
|
|
id = 5
|
|
|
|
group = 'dev'
|
|
|
|
short = 'upgrade_success'
|
|
|
|
label = _("my add-on's compatibility is upgraded successfully")
|
|
|
|
mandatory = False
|
|
|
|
default_checked = True
|
|
|
|
|
|
|
|
|
|
|
|
class sdk_upgrade_success(_NOTIFICATION):
|
|
|
|
id = 6
|
|
|
|
group = 'dev'
|
|
|
|
short = 'sdk_upgrade_success'
|
|
|
|
label = _("my sdk-based add-on is upgraded successfully")
|
|
|
|
mandatory = False
|
|
|
|
default_checked = True
|
|
|
|
|
|
|
|
|
|
|
|
class new_review(_NOTIFICATION):
|
|
|
|
id = 7
|
|
|
|
group = 'dev'
|
|
|
|
short = 'new_review'
|
|
|
|
label = _("someone writes a review of my add-on")
|
|
|
|
mandatory = False
|
|
|
|
default_checked = True
|
|
|
|
|
|
|
|
|
2011-11-19 08:52:25 +04:00
|
|
|
class app_new_review(new_review):
|
|
|
|
app = True
|
|
|
|
label = loc('someone writes a review of my app')
|
|
|
|
|
|
|
|
|
2011-07-19 02:49:15 +04:00
|
|
|
class announcements(_NOTIFICATION):
|
|
|
|
id = 8
|
|
|
|
group = 'dev'
|
|
|
|
short = 'announcements'
|
|
|
|
label = _("add-on contests or events are announced")
|
|
|
|
mandatory = False
|
|
|
|
default_checked = True
|
|
|
|
|
|
|
|
|
|
|
|
class upgrade_fail(_NOTIFICATION):
|
|
|
|
id = 9
|
|
|
|
group = 'dev'
|
|
|
|
short = 'upgrade_fail'
|
|
|
|
label = _("my add-on's compatibility cannot be upgraded")
|
|
|
|
mandatory = True
|
|
|
|
default_checked = True
|
|
|
|
|
|
|
|
|
|
|
|
class sdk_upgrade_fail(_NOTIFICATION):
|
|
|
|
id = 10
|
|
|
|
group = 'dev'
|
|
|
|
short = 'sdk_upgrade_fail'
|
2011-07-23 03:58:24 +04:00
|
|
|
label = _("my sdk-based add-on cannot be upgraded")
|
2011-07-19 02:49:15 +04:00
|
|
|
mandatory = True
|
|
|
|
default_checked = True
|
|
|
|
|
|
|
|
|
|
|
|
class editor_reviewed(_NOTIFICATION):
|
|
|
|
id = 11
|
|
|
|
group = 'dev'
|
|
|
|
short = 'editor_reviewed'
|
|
|
|
label = _("my add-on is reviewed by an editor")
|
|
|
|
mandatory = True
|
|
|
|
default_checked = True
|
|
|
|
|
|
|
|
|
|
|
|
class individual_contact(_NOTIFICATION):
|
|
|
|
id = 12
|
|
|
|
group = 'dev'
|
|
|
|
short = 'individual_contact'
|
|
|
|
label = _("Mozilla needs to contact me about my individual add-on")
|
|
|
|
mandatory = True
|
|
|
|
default_checked = True
|
|
|
|
|
|
|
|
|
2011-11-19 08:52:25 +04:00
|
|
|
class app_individual_contact(individual_contact):
|
|
|
|
app = True
|
|
|
|
label = loc('Mozilla needs to contact me about my individual app')
|
|
|
|
|
2011-07-19 02:49:15 +04:00
|
|
|
|
|
|
|
NOTIFICATION_GROUPS = {'dev': _('Developer'),
|
|
|
|
'user': _('User Notifications')}
|
|
|
|
|
|
|
|
NOTIFICATIONS = [x for x in vars().values()
|
|
|
|
if isclass(x) and issubclass(x, _NOTIFICATION)
|
2011-11-19 08:52:25 +04:00
|
|
|
and x != _NOTIFICATION and not getattr(x, 'app', False)]
|
2011-07-19 02:49:15 +04:00
|
|
|
NOTIFICATIONS_BY_ID = dict((l.id, l) for l in NOTIFICATIONS)
|
2011-07-22 02:39:55 +04:00
|
|
|
NOTIFICATIONS_BY_SHORT = dict((l.short, l) for l in NOTIFICATIONS)
|
2011-07-19 02:49:15 +04:00
|
|
|
NOTIFICATION = AttributeDict((l.__name__, l) for l in NOTIFICATIONS)
|
|
|
|
|
|
|
|
NOTIFICATIONS_DEFAULT = [l.id for l in NOTIFICATIONS if l.default_checked]
|
|
|
|
NOTIFICATIONS_CHOICES = [(l.id, l.label) for l in NOTIFICATIONS]
|
2011-07-26 02:37:43 +04:00
|
|
|
NOTIFICATIONS_CHOICES_NOT_DEV = [(l.id, l.label) for l in NOTIFICATIONS
|
|
|
|
if l.group != 'dev']
|
2011-07-19 02:49:15 +04:00
|
|
|
|
2011-11-19 08:52:25 +04:00
|
|
|
APP_NOTIFICATIONS = [app_reply, app_new_review, app_individual_contact]
|
|
|
|
APP_NOTIFICATIONS_DEFAULT = [l.id for l in APP_NOTIFICATIONS]
|
|
|
|
APP_NOTIFICATIONS_CHOICES = [(l.id, l.label) for l in APP_NOTIFICATIONS]
|
|
|
|
APP_NOTIFICATIONS_CHOICES_NOT_DEV = [(l.id, l.label) for l in APP_NOTIFICATIONS
|
|
|
|
if l.group != 'dev']
|