from app.utils import log from notifications.models import Notification from django.contrib.auth.models import User from projects.models import Project from error.signals import error_created amo_users = ['*****@*****.**'] amo_domains = ['addons-dev.allizom.org', 'addons.allizom.org', 'addons.mozilla.org', 'apps-preview-dev.allizom.org', 'apps-preview.allizom.org', 'apps-preview.mozilla.org', 'marketplace-dev.allizom.org', 'marketplace.allizom.org', 'marketplace.mozilla.org'] def amo_notification(instance, **kw): """ Given an error see if we need to send a notification """ log('Firing signal: default_notification') user = User.objects.get(email__in=amo_users) if instance.domain in amo_domains: notification = Notification() notification.notifier = instance notification.save() notification.user.add(user) error_created.connect(amo_notification, dispatch_uid='amo_notification')
filtered = [] for user in users: profile = get_profile(user) if profile.notification and instance.priority <= profile.notification: filtered.append(user) if not filtered: return notification = Notification() notification.type = "Error" notification.type_key = str(instance.key()) notification.user = [ str(u.key()) for u in filtered ] notification.save() error_created.connect(default_notification, dispatch_uid="default_notification") def default_issue_notification(instance, **kw): """ Given an issue see default_issue_notification we need to send a notification """ log("Firing signal: default_notification") users = approved_users() if not users.count(): return notification = Notification() notification.type = "Issue" notification.type_key = str(instance.key()) notification.user = [ str(u.key()) for u in users ] notification.save()
for user in users: profile = get_profile(user) if profile.notification and instance.priority <= profile.notification: filtered.append(user) if not filtered: return notification = Notification() notification.type = "Error" notification.type_key = str(instance.key()) notification.user = [str(u.key()) for u in filtered] notification.save() error_created.connect(default_notification, dispatch_uid="default_notification") def default_issue_notification(instance, **kw): """ Given an issue see default_issue_notification we need to send a notification """ log("Firing signal: default_notification") users = approved_users() if not users.count(): return notification = Notification() notification.type = "Issue" notification.type_key = str(instance.key()) notification.user = [str(u.key()) for u in users]