Fixed #21718 -- Renamed has_app to is_installed.

This commit is contained in:
Aymeric Augustin 2014-01-06 22:48:41 +01:00
parent b57c48d012
commit 6a320cc14a
10 changed files with 15 additions and 15 deletions

View File

@ -192,7 +192,7 @@ class Apps(object):
app_models[model_name] = model app_models[model_name] = model
self.clear_cache() self.clear_cache()
def has_app(self, app_name): def is_installed(self, app_name):
""" """
Checks whether an application with this name exists in the registry. Checks whether an application with this name exists in the registry.

View File

@ -160,10 +160,10 @@ class AdminSite(object):
The default implementation checks that admin and contenttypes apps are The default implementation checks that admin and contenttypes apps are
installed, as well as the auth context processor. installed, as well as the auth context processor.
""" """
if not apps.has_app('django.contrib.admin'): if not apps.is_installed('django.contrib.admin'):
raise ImproperlyConfigured("Put 'django.contrib.admin' in your " raise ImproperlyConfigured("Put 'django.contrib.admin' in your "
"INSTALLED_APPS setting in order to use the admin application.") "INSTALLED_APPS setting in order to use the admin application.")
if not apps.has_app('django.contrib.contenttypes'): if not apps.is_installed('django.contrib.contenttypes'):
raise ImproperlyConfigured("Put 'django.contrib.contenttypes' in " raise ImproperlyConfigured("Put 'django.contrib.contenttypes' in "
"your INSTALLED_APPS setting in order to use the admin application.") "your INSTALLED_APPS setting in order to use the admin application.")
if 'django.contrib.auth.context_processors.auth' not in settings.TEMPLATE_CONTEXT_PROCESSORS: if 'django.contrib.auth.context_processors.auth' not in settings.TEMPLATE_CONTEXT_PROCESSORS:

View File

@ -3,7 +3,7 @@ from django.template import Library
register = Library() register = Library()
if apps.has_app('django.contrib.staticfiles'): if apps.is_installed('django.contrib.staticfiles'):
from django.contrib.staticfiles.templatetags.staticfiles import static from django.contrib.staticfiles.templatetags.staticfiles import static
else: else:
from django.templatetags.static import static from django.templatetags.static import static

View File

@ -15,7 +15,7 @@ from django.utils.translation import ugettext_lazy
def skipUnlessAuthIsInstalled(func): def skipUnlessAuthIsInstalled(func):
return skipUnless( return skipUnless(
apps.has_app('django.contrib.auth'), apps.is_installed('django.contrib.auth'),
"django.contrib.auth isn't installed")(func) "django.contrib.auth isn't installed")(func)

View File

@ -15,7 +15,7 @@ class RedirectFallbackMiddleware(object):
response_redirect_class = http.HttpResponsePermanentRedirect response_redirect_class = http.HttpResponsePermanentRedirect
def __init__(self): def __init__(self):
if not apps.has_app('django.contrib.sites'): if not apps.is_installed('django.contrib.sites'):
raise ImproperlyConfigured( raise ImproperlyConfigured(
"You cannot use RedirectFallbackMiddleware when " "You cannot use RedirectFallbackMiddleware when "
"django.contrib.sites is not installed." "django.contrib.sites is not installed."

View File

@ -10,7 +10,7 @@ from .base import SitemapTestsBase
class FlatpagesSitemapTests(SitemapTestsBase): class FlatpagesSitemapTests(SitemapTestsBase):
@skipUnless(apps.has_app('django.contrib.flatpages'), @skipUnless(apps.is_installed('django.contrib.flatpages'),
"django.contrib.flatpages app not installed.") "django.contrib.flatpages app not installed.")
def test_flatpage_sitemap(self): def test_flatpage_sitemap(self):
"Basic FlatPage sitemap test" "Basic FlatPage sitemap test"

View File

@ -118,7 +118,7 @@ class HTTPSitemapTests(SitemapTestsBase):
""" % date.today() """ % date.today()
self.assertXMLEqual(response.content.decode('utf-8'), expected_content) self.assertXMLEqual(response.content.decode('utf-8'), expected_content)
@skipUnless(apps.has_app('django.contrib.sites'), @skipUnless(apps.is_installed('django.contrib.sites'),
"django.contrib.sites app not installed.") "django.contrib.sites app not installed.")
def test_sitemap_get_urls_no_site_1(self): def test_sitemap_get_urls_no_site_1(self):
""" """

View File

@ -390,7 +390,7 @@ class Client(RequestFactory):
""" """
Obtains the current session variables. Obtains the current session variables.
""" """
if apps.has_app('django.contrib.sessions'): if apps.is_installed('django.contrib.sessions'):
engine = import_module(settings.SESSION_ENGINE) engine = import_module(settings.SESSION_ENGINE)
cookie = self.cookies.get(settings.SESSION_COOKIE_NAME, None) cookie = self.cookies.get(settings.SESSION_COOKIE_NAME, None)
if cookie: if cookie:
@ -551,7 +551,7 @@ class Client(RequestFactory):
""" """
user = authenticate(**credentials) user = authenticate(**credentials)
if (user and user.is_active and if (user and user.is_active and
apps.has_app('django.contrib.sessions')): apps.is_installed('django.contrib.sessions')):
engine = import_module(settings.SESSION_ENGINE) engine = import_module(settings.SESSION_ENGINE)
# Create a fake request that goes through request middleware # Create a fake request that goes through request middleware

View File

@ -203,7 +203,7 @@ Application registry
given ``app_label``. Raises :exc:`~exceptions.LookupError` if no such given ``app_label``. Raises :exc:`~exceptions.LookupError` if no such
application exists. application exists.
.. method:: apps.has_app(app_name) .. method:: apps.is_installed(app_name)
Checks whether an application with the given name exists in the registry. Checks whether an application with the given name exists in the registry.
``app_name`` is the full name of the app, e.g. 'django.contrib.admin'. ``app_name`` is the full name of the app, e.g. 'django.contrib.admin'.

View File

@ -107,10 +107,10 @@ class AppsTests(TestCase):
apps.get_app_config('webdesign') apps.get_app_config('webdesign')
@override_settings(INSTALLED_APPS=SOME_INSTALLED_APPS) @override_settings(INSTALLED_APPS=SOME_INSTALLED_APPS)
def test_has_app(self): def test_is_installed(self):
self.assertTrue(apps.has_app('django.contrib.admin')) self.assertTrue(apps.is_installed('django.contrib.admin'))
self.assertTrue(apps.has_app('django.contrib.staticfiles')) self.assertTrue(apps.is_installed('django.contrib.staticfiles'))
self.assertFalse(apps.has_app('django.contrib.webdesign')) self.assertFalse(apps.is_installed('django.contrib.webdesign'))
@override_settings(INSTALLED_APPS=['apps.apps.RelabeledAppsConfig']) @override_settings(INSTALLED_APPS=['apps.apps.RelabeledAppsConfig'])
def test_relabeling(self): def test_relabeling(self):