diff --git a/readthedocs/notifications/backends.py b/readthedocs/notifications/backends.py index 390df3dac95..bcd9eaa8c68 100644 --- a/readthedocs/notifications/backends.py +++ b/readthedocs/notifications/backends.py @@ -1,9 +1,9 @@ """Notification to message backends""" from django.conf import settings -from django.contrib.messages import add_message from django.utils.module_loading import import_string from messages_extends.constants import INFO_PERSISTENT +from messages_extends import add_message from readthedocs.core.utils import send_email @@ -75,4 +75,5 @@ def send(self, notification): ), level=LEVEL_MAPPING.get(notification.level, INFO_PERSISTENT), extra_tags='', + user=notification.user, ) diff --git a/readthedocs/rtd_tests/tests/test_notifications.py b/readthedocs/rtd_tests/tests/test_notifications.py index bab883d8764..388b94aa9ea 100644 --- a/readthedocs/rtd_tests/tests/test_notifications.py +++ b/readthedocs/rtd_tests/tests/test_notifications.py @@ -4,6 +4,7 @@ import django_dynamic_fixture as fixture from django.test import TestCase from django.test.utils import override_settings +from django.contrib.auth.models import User from readthedocs.notifications import Notification from readthedocs.notifications.backends import EmailBackend, SiteBackend @@ -76,11 +77,13 @@ class TestNotification(Notification): context_object_name = 'foo' build = fixture.get(Build) + user = fixture.get(User) req = mock.MagicMock() - notify = TestNotification(object=build, request=req) + notify = TestNotification(object=build, request=req, user=user) backend = SiteBackend(request=req) backend.send(notify) add_message.assert_has_calls([ - mock.call(level=21, request=req, message=mock.ANY, extra_tags='') + mock.call(level=21, request=req, message=mock.ANY, extra_tags='', + user=user) ])