mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 11:51:05 -05:00
Deprecate DjrillAdminSite
This commit is contained in:
@@ -2,7 +2,7 @@ from django.conf import settings
|
|||||||
from django.contrib.admin.sites import AdminSite
|
from django.contrib.admin.sites import AdminSite
|
||||||
from django.utils.text import capfirst
|
from django.utils.text import capfirst
|
||||||
|
|
||||||
from djrill.exceptions import MandrillAPIError, NotSupportedByMandrillError
|
from djrill.exceptions import MandrillAPIError, NotSupportedByMandrillError, removed_in_djrill_2
|
||||||
|
|
||||||
from ._version import *
|
from ._version import *
|
||||||
|
|
||||||
@@ -17,6 +17,15 @@ class DjrillAdminSite(AdminSite):
|
|||||||
# If new versions of Django break DjrillAdminSite, it's worth checking to see
|
# If new versions of Django break DjrillAdminSite, it's worth checking to see
|
||||||
# whether django-adminplus has dealt with something similar.
|
# whether django-adminplus has dealt with something similar.
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
removed_in_djrill_2(
|
||||||
|
"DjrillAdminSite will be removed in Djrill 2.0. "
|
||||||
|
"You should remove references to it from your code. "
|
||||||
|
"(All of its data is available in the Mandrill dashboard.)"
|
||||||
|
)
|
||||||
|
super(DjrillAdminSite, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
index_template = "djrill/index.html"
|
index_template = "djrill/index.html"
|
||||||
custom_views = []
|
custom_views = []
|
||||||
custom_urls = []
|
custom_urls = []
|
||||||
|
|||||||
@@ -6,14 +6,9 @@ from django.contrib.auth.models import User
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
from djrill.exceptions import RemovedInDjrill2
|
||||||
from djrill.tests.mock_backend import DjrillBackendMockAPITestCase
|
from djrill.tests.mock_backend import DjrillBackendMockAPITestCase
|
||||||
|
from djrill.tests.utils import override_settings
|
||||||
from .utils import override_settings
|
|
||||||
|
|
||||||
# We don't care that the `cycle` template tag will be removed in Django 2.0,
|
|
||||||
# because we're planning to drop the Djrill admin templates before then.
|
|
||||||
warnings.filterwarnings('ignore', category=PendingDeprecationWarning,
|
|
||||||
message="Loading the `cycle` tag from the `future` library")
|
|
||||||
|
|
||||||
|
|
||||||
def reset_admin_site():
|
def reset_admin_site():
|
||||||
@@ -34,6 +29,21 @@ class DjrillAdminTests(DjrillBackendMockAPITestCase):
|
|||||||
# so return it to the default state before loading test_admin_urls
|
# so return it to the default state before loading test_admin_urls
|
||||||
reset_admin_site()
|
reset_admin_site()
|
||||||
|
|
||||||
|
def run(self, result=None):
|
||||||
|
with warnings.catch_warnings():
|
||||||
|
# DjrillAdminSite deprecation is tested in test_legacy
|
||||||
|
warnings.filterwarnings('ignore', category=RemovedInDjrill2,
|
||||||
|
message="DjrillAdminSite will be removed in Djrill 2.0")
|
||||||
|
# We don't care that the `cycle` template tag will be removed in Django 2.0,
|
||||||
|
# because we're planning to drop the Djrill admin templates before then.
|
||||||
|
warnings.filterwarnings('ignore', category=PendingDeprecationWarning,
|
||||||
|
message="Loading the `cycle` tag from the `future` library")
|
||||||
|
# We don't care that user messaging was deprecated in Django 1.3
|
||||||
|
# (testing artifact of our runtests.py minimal Django settings)
|
||||||
|
warnings.filterwarnings('ignore', category=DeprecationWarning,
|
||||||
|
message="The user messaging API is deprecated.")
|
||||||
|
super(DjrillAdminTests, self).run(result)
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(DjrillAdminTests, self).setUp()
|
super(DjrillAdminTests, self).setUp()
|
||||||
# Must be authenticated staff to access admin site...
|
# Must be authenticated staff to access admin site...
|
||||||
|
|||||||
@@ -6,14 +6,24 @@ import warnings
|
|||||||
from django.core import mail
|
from django.core import mail
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
|
from djrill import MandrillAPIError, NotSupportedByMandrillError, DjrillAdminSite
|
||||||
from djrill.mail import DjrillMessage
|
from djrill.mail import DjrillMessage
|
||||||
from djrill import MandrillAPIError, NotSupportedByMandrillError
|
from djrill.tests.mock_backend import DjrillBackendMockAPITestCase
|
||||||
|
from djrill.tests.utils import reset_warning_registry
|
||||||
from .mock_backend import DjrillBackendMockAPITestCase
|
|
||||||
|
|
||||||
|
|
||||||
class DjrillBackendDeprecationTests(DjrillBackendMockAPITestCase):
|
class DjrillBackendDeprecationTests(DjrillBackendMockAPITestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
reset_warning_registry()
|
||||||
|
super(DjrillBackendDeprecationTests, self).setUp()
|
||||||
|
|
||||||
|
def test_deprecated_admin_site(self):
|
||||||
|
"""Djrill 2.0 drops the custom DjrillAdminSite"""
|
||||||
|
self.assertWarnsMessage(DeprecationWarning,
|
||||||
|
"DjrillAdminSite will be removed in Djrill 2.0",
|
||||||
|
DjrillAdminSite)
|
||||||
|
|
||||||
def test_deprecated_json_date_encoding(self):
|
def test_deprecated_json_date_encoding(self):
|
||||||
"""Djrill 2.0+ avoids a blanket JSONDateUTCEncoder"""
|
"""Djrill 2.0+ avoids a blanket JSONDateUTCEncoder"""
|
||||||
# Djrill allows dates for send_at, so shouldn't warn:
|
# Djrill allows dates for send_at, so shouldn't warn:
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import re
|
import re
|
||||||
import six
|
import six
|
||||||
|
import sys
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
'BackportedAssertions',
|
'BackportedAssertions',
|
||||||
'override_settings',
|
'override_settings',
|
||||||
|
'reset_warning_registry',
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -86,3 +88,18 @@ class BackportedAssertions(object):
|
|||||||
callable_obj=None, *args, **kwargs):
|
callable_obj=None, *args, **kwargs):
|
||||||
return six.assertRaisesRegex(self, expected_exception, re.escape(expected_message),
|
return six.assertRaisesRegex(self, expected_exception, re.escape(expected_message),
|
||||||
callable_obj, *args, **kwargs)
|
callable_obj, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
# Backport from Django 1.8 (django.test.utils)
|
||||||
|
def reset_warning_registry():
|
||||||
|
"""
|
||||||
|
Clear warning registry for all modules. This is required in some tests
|
||||||
|
because of a bug in Python that prevents warnings.simplefilter("always")
|
||||||
|
from always making warnings appear: http://bugs.python.org/issue4180
|
||||||
|
|
||||||
|
The bug was fixed in Python 3.4.2.
|
||||||
|
"""
|
||||||
|
key = "__warningregistry__"
|
||||||
|
for mod in sys.modules.values():
|
||||||
|
if hasattr(mod, key):
|
||||||
|
getattr(mod, key).clear()
|
||||||
|
|||||||
@@ -16,6 +16,20 @@ version of Djrill (1.4) will try to warn you if you use things
|
|||||||
that will change. (Warnings appear in the console when running Django
|
that will change. (Warnings appear in the console when running Django
|
||||||
in debug mode.)
|
in debug mode.)
|
||||||
|
|
||||||
|
* **Djrill Admin site**
|
||||||
|
|
||||||
|
Djrill 2.0 will remove the custom Djrill admin site. It duplicates
|
||||||
|
information from Mandrill's dashboard, most Djrill users are unaware
|
||||||
|
it exists, and it has caused problems tracking Django admin changes.
|
||||||
|
|
||||||
|
Drill 1.4 will report a `DeprecationWarning` when you try to load
|
||||||
|
the `DjrillAdminSite`. You should remove it from your code.
|
||||||
|
|
||||||
|
Also, if you changed :setting:`INSTALLED_APPS` to use
|
||||||
|
`'django.contrib.admin.apps.SimpleAdminConfig'`, you may be able to
|
||||||
|
switch that back to `'django.contrib.admin'` and let Django
|
||||||
|
handle the `admin.autodiscover()` for you.
|
||||||
|
|
||||||
* **Dates in merge data and other attributes**
|
* **Dates in merge data and other attributes**
|
||||||
|
|
||||||
Djrill automatically converts :attr:`send_at` `date` and `datetime`
|
Djrill automatically converts :attr:`send_at` `date` and `datetime`
|
||||||
|
|||||||
Reference in New Issue
Block a user