Don't crash on subscribers without a profile
authorMagnus Hagander <magnus@hagander.net>
Sat, 27 Feb 2016 14:21:02 +0000 (09:21 -0500)
committerMagnus Hagander <magnus@hagander.net>
Sat, 27 Feb 2016 14:21:02 +0000 (09:21 -0500)
pgcommitfest/commitfest/management/commands/send_notifications.py

index 634af587e980647f07b9d16f4c6416d7f38f1e20..6a8fe42ab49ca9b5f872c0f52e13c7e2879c6144 100644 (file)
@@ -5,6 +5,7 @@ from django.conf import settings
 from StringIO import StringIO
 
 from pgcommitfest.commitfest.models import PendingNotification
+from pgcommitfest.userprofile.models import UserProfile
 from pgcommitfest.mailqueue.util import send_template_mail
 
 class Command(BaseCommand):
@@ -27,8 +28,11 @@ class Command(BaseCommand):
                        for v in matches.values():
                                user = v['user']
                                email = user.email
-                               if user.userprofile and user.userprofile.notifyemail:
-                                       email = user.userprofile.notifyemail.email
+                               try:
+                                       if user.userprofile and user.userprofile.notifyemail:
+                                               email = user.userprofile.notifyemail.email
+                               except UserProfile.DoesNotExist:
+                                       pass
 
                                send_template_mail(settings.NOTIFICATION_FROM,
                                                                   None,