From fa2e343cb7fe4ed0694d197635a8d8b97cbd1b50 Mon Sep 17 00:00:00 2001 From: Florian Demmer Date: Wed, 5 Jul 2017 15:15:47 +0200 Subject: [PATCH] Rename all settings with the old "polla" name, this is a breaking change! --- airavata/settings.py | 6 +++--- airavata/staticfiles_finder.py | 2 +- airavata/template_loader.py | 2 +- airavata/templatetags/sitestatic.py | 2 +- airavata/urls.py | 10 +++++----- airavata/utils.py | 2 +- docs/advanced.rst | 14 +++++++------- settings.py | 2 +- test_app/tests/test_unit.py | 4 ++-- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/airavata/settings.py b/airavata/settings.py index edcc878..151be7a 100644 --- a/airavata/settings.py +++ b/airavata/settings.py @@ -1,11 +1,11 @@ import os -POLLA_BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +AIRAVATA_BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) ## Sites specific files base directory -POLLA_SITES_DIR = os.path.join(POLLA_BASE_DIR, 'sites') +AIRAVATA_SITES_DIR = os.path.join(AIRAVATA_BASE_DIR, 'sites') ## should dots from domain names be replaced by underscores for ## paths used in templates, staticfiles and urls loaders -POLLA_REPLACE_DOTS_IN_DOMAINS = False +AIRAVATA_REPLACE_DOTS_IN_DOMAINS = False diff --git a/airavata/staticfiles_finder.py b/airavata/staticfiles_finder.py index 29c8b50..6ad2224 100644 --- a/airavata/staticfiles_finder.py +++ b/airavata/staticfiles_finder.py @@ -16,7 +16,7 @@ def __init__(self, app_name=None, *args, **kwargs): self.storages = OrderedDict() for site in Site.objects.all(): current = get_domain_path(site.domain) - root = os.path.join(settings.POLLA_SITES_DIR, current, 'static') + root = os.path.join(settings.AIRAVATA_SITES_DIR, current, 'static') if os.path.exists(root) and (current, root) not in self.locations: self.locations.append((current, root)) diff --git a/airavata/template_loader.py b/airavata/template_loader.py index ae72e75..5de99e6 100644 --- a/airavata/template_loader.py +++ b/airavata/template_loader.py @@ -25,7 +25,7 @@ def get_template_sources(self, template_name, template_dirs=None): return False try: - return safe_join(settings.POLLA_SITES_DIR, current, 'templates', template_name) + return safe_join(settings.AIRAVATA_SITES_DIR, current, 'templates', template_name) except SuspiciousFileOperation: return False diff --git a/airavata/templatetags/sitestatic.py b/airavata/templatetags/sitestatic.py index d872e0e..6b0de1d 100644 --- a/airavata/templatetags/sitestatic.py +++ b/airavata/templatetags/sitestatic.py @@ -12,7 +12,7 @@ def static(path): site_path = get_current_path() - if os.path.exists(os.path.join(settings.POLLA_SITES_DIR, site_path, 'static', path)): + if os.path.exists(os.path.join(settings.AIRAVATA_SITES_DIR, site_path, 'static', path)): return staticfiles_storage.url(os.path.join(site_path, path)) return staticfiles_storage.url(path) diff --git a/airavata/urls.py b/airavata/urls.py index f5ab977..ce2fba5 100644 --- a/airavata/urls.py +++ b/airavata/urls.py @@ -7,13 +7,13 @@ from django.conf import settings -POLLA_PATCHED_RESOLVER = False +AIRAVATA_PATCHED_RESOLVER = False class UrlPatterns(object): def __init__(self, defaults=[]): - if not settings.POLLA_REPLACE_DOTS_IN_DOMAINS: - raise ImproperlyConfigured("POLLA_REPLACE_DOTS_IN_DOMAINS needs to be set to True in order to use this functionality") + if not settings.AIRAVATA_REPLACE_DOTS_IN_DOMAINS: + raise ImproperlyConfigured("AIRAVATA_REPLACE_DOTS_IN_DOMAINS needs to be set to True in order to use this functionality") self.defaults = defaults self.extras = [] @@ -93,9 +93,9 @@ def __reversed__(self): to_reverse = list(self.get_current_urls()) return reversed(to_reverse) -if not POLLA_PATCHED_RESOLVER: +if not AIRAVATA_PATCHED_RESOLVER: from .utils import get_resolver, get_ns_resolver from django.core import urlresolvers urlresolvers.get_resolver = get_resolver urlresolvers.get_ns_resolver = get_ns_resolver - POLLA_PATCHED_RESOLVER = True + AIRAVATA_PATCHED_RESOLVER = True diff --git a/airavata/utils.py b/airavata/utils.py index 44635be..b5bb6bb 100644 --- a/airavata/utils.py +++ b/airavata/utils.py @@ -81,7 +81,7 @@ def get_current_site(request=None): ## Loaders def get_domain_path(domain): - if settings.POLLA_REPLACE_DOTS_IN_DOMAINS: + if settings.AIRAVATA_REPLACE_DOTS_IN_DOMAINS: domain = domain.replace('.', '_') return domain.lower() diff --git a/docs/advanced.rst b/docs/advanced.rst index 9034145..67ad84b 100644 --- a/docs/advanced.rst +++ b/docs/advanced.rst @@ -27,19 +27,19 @@ To use any of the following features, make sure you enable `LocalThreadMiddlewar ) -POLLA_SITES_DIR +AIRAVATA_SITES_DIR ~~~~~~~~~~~~~~~ -Every site-specific feature (template, urls, static file) is hosted under a main directory (``BASE_DIR/sites`` by default), to override it, provide ``POLLA_SITES_DIR`` in your ``settings.py`` +Every site-specific feature (template, urls, static file) is hosted under a main directory (``BASE_DIR/sites`` by default), to override it, provide ``AIRAVATA_SITES_DIR`` in your ``settings.py`` -POLLA_REPLACE_DOTS_IN_DOMAINS +AIRAVATA_REPLACE_DOTS_IN_DOMAINS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This setting is set to ``False`` by default. For people wanting to use Airavata as a drop-in replacement for ``dynamicsites`` or who would like to use the **Urls** feature, you shoud set it to ``True``. -Setting ``POLLA_REPLACE_DOTS_IN_DOMAINS`` will change the default behaviour when it comes to looking for site specific features. +Setting ``AIRAVATA_REPLACE_DOTS_IN_DOMAINS`` will change the default behaviour when it comes to looking for site specific features. -e.g: you are trying to load a template named ``base.html`` for the site ``example.com``. having ``POLLA_REPLACE_DOTS_IN_DOMAINS`` set to ``True`` django will try looking for it under ``sites/example_com/templates/base.html`` instead of the default ``sites/example.com/templates/base.html`` +e.g: you are trying to load a template named ``base.html`` for the site ``example.com``. having ``AIRAVATA_REPLACE_DOTS_IN_DOMAINS`` set to ``True`` django will try looking for it under ``sites/example_com/templates/base.html`` instead of the default ``sites/example.com/templates/base.html`` .. note:: In any case directory names are lower-case @@ -48,7 +48,7 @@ e.g: you are trying to load a template named ``base.html`` for the site ``exampl TemplateLoader -------------- -Airavata provides a TemplateLoader allowing you to load different templates according to the requested host. Specific templates should be placed under the directory configured in ``POLLA_SITES_DIR`` under a sub-directory corresponding to the main domain name (the domain name in ``Site``). +Airavata provides a TemplateLoader allowing you to load different templates according to the requested host. Specific templates should be placed under the directory configured in ``AIRAVATA_SITES_DIR`` under a sub-directory corresponding to the main domain name (the domain name in ``Site``). To enable Airavata's template loader, you have to make the following changes to your settings.py: :: @@ -121,7 +121,7 @@ UrlPatterns ----------- .. note:: - To use this feature, make sure you set ``POLLA_REPLACE_DOTS_IN_DOMAINS`` to ``True`` in your ``settings.py`` + To use this feature, make sure you set ``AIRAVATA_REPLACE_DOTS_IN_DOMAINS`` to ``True`` in your ``settings.py`` On Python 2 also make sure to include ``__init__.py`` in both ``sites`` and it's sub_directory Airavata allows you to define different urlpatterns for specific domains. To use this feature, update your main ``urls.py`` to look like this diff --git a/settings.py b/settings.py index d17ad1e..a2d8e78 100644 --- a/settings.py +++ b/settings.py @@ -126,4 +126,4 @@ "django.contrib.staticfiles.finders.AppDirectoriesFinder", ) -POLLA_REPLACE_DOTS_IN_DOMAINS = True +AIRAVATA_REPLACE_DOTS_IN_DOMAINS = True diff --git a/test_app/tests/test_unit.py b/test_app/tests/test_unit.py index c5fad29..14c1eb0 100644 --- a/test_app/tests/test_unit.py +++ b/test_app/tests/test_unit.py @@ -68,11 +68,11 @@ def testModel(self): class UtilsTest(TestCase): def test_dont_replace_dots_get_domain_path(self): - with self.settings(POLLA_REPLACE_DOTS_IN_DOMAINS=False): + with self.settings(AIRAVATA_REPLACE_DOTS_IN_DOMAINS=False): self.assertEqual(get_domain_path('exAmple.com'), 'example.com') def test_replace_dots_get_domain_path(self): - with self.settings(POLLA_REPLACE_DOTS_IN_DOMAINS=True): + with self.settings(AIRAVATA_REPLACE_DOTS_IN_DOMAINS=True): self.assertEqual(get_domain_path('exAmple.com'), 'example_com')