From 5915ec1f0e7962eccb9c2aa17467f9ca3753318f Mon Sep 17 00:00:00 2001 From: Anurag Sharma Date: Wed, 7 Oct 2015 20:44:15 +0530 Subject: [PATCH 1/3] Changed EMBEDLY_KEY to WAGTAILEMBEDS_EMBEDY_KEY --- docs/advanced_topics/settings.rst | 4 ++-- wagtail/wagtailembeds/embeds.py | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/docs/advanced_topics/settings.rst b/docs/advanced_topics/settings.rst index 6cf61e98fb..fc791483d7 100644 --- a/docs/advanced_topics/settings.rst +++ b/docs/advanced_topics/settings.rst @@ -184,7 +184,7 @@ Use a custom embed finder function, which takes a URL and returns a dict with me .. code-block:: python # not a working key, get your own! - EMBEDLY_KEY = '253e433d59dc4d2xa266e9e0de0cb830' + WAGTAILEMBEDS_EMBEDLY_KEY = '253e433d59dc4d2xa266e9e0de0cb830' Providing an API key for the Embedly service will use that as a embed backend, with a more extensive list of providers, as well as analytics and other features. For more information, see `Embedly`_. @@ -515,7 +515,7 @@ These two files should reside in your project directory (``myproject/myproject/` # If you want to use Embedly for embeds, supply a key # (this key doesn't work, get your own!) - # EMBEDLY_KEY = '253e433d59dc4d2xa266e9e0de0cb830' + # WAGTAILEMBEDS_EMBEDLY_KEY = '253e433d59dc4d2xa266e9e0de0cb830' ``urls.py`` diff --git a/wagtail/wagtailembeds/embeds.py b/wagtail/wagtailembeds/embeds.py index 4b4f9d392d..9aea87d2f0 100644 --- a/wagtail/wagtailembeds/embeds.py +++ b/wagtail/wagtailembeds/embeds.py @@ -1,5 +1,6 @@ from datetime import datetime import json +import warnings # Needs to be imported like this to allow @patch to work in tests from django.utils.six.moves.urllib import request as urllib_request @@ -11,6 +12,7 @@ from django.conf import settings from wagtail.wagtailembeds.oembed_providers import get_oembed_provider from wagtail.wagtailembeds.models import Embed +from wagtail.utils.deprecation import RemovedInWagtail14Warning class EmbedException(Exception): @@ -31,7 +33,13 @@ def embedly(url, max_width=None, key=None): # Get embedly key if key is None: - key = settings.EMBEDLY_KEY + try: + key = settings.WAGTAILEMBEDS_EMBEDLY_KEY + except AttributeError: + key = settings.EMBEDLY_KEY + warnings.warn( + "EMBEDLY_KEY is now deprecated. Use WAGTAILEMBEDS_EMBEDLY_KEY instead", + RemovedInWagtail14Warning) # Get embedly client client = Embedly(key=key) @@ -115,7 +123,12 @@ def get_default_finder(): return import_string(settings.WAGTAILEMBEDS_EMBED_FINDER) # Use embedly if the embedly key is set - if hasattr(settings, 'EMBEDLY_KEY'): + if hasattr(settings, 'WAGTAILEMBEDS_EMBEDLY_KEY'): + return embedly + elif hasattr(settings, 'EMBEDLY_KEY'): + warnings.warn( + "use WAGTAILEMBEDS_EMBEDLY_KEY instead.", + RemovedInWagtail14Warning) return embedly # Fall back to oembed From ce16e2cf08c4f3a4bdefffe16b1a5606ff63260b Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Thu, 8 Oct 2015 09:32:18 +0100 Subject: [PATCH 2/3] Removed unneeded check --- wagtail/wagtailembeds/embeds.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/wagtail/wagtailembeds/embeds.py b/wagtail/wagtailembeds/embeds.py index 9aea87d2f0..ccbd37c732 100644 --- a/wagtail/wagtailembeds/embeds.py +++ b/wagtail/wagtailembeds/embeds.py @@ -123,12 +123,7 @@ def get_default_finder(): return import_string(settings.WAGTAILEMBEDS_EMBED_FINDER) # Use embedly if the embedly key is set - if hasattr(settings, 'WAGTAILEMBEDS_EMBEDLY_KEY'): - return embedly - elif hasattr(settings, 'EMBEDLY_KEY'): - warnings.warn( - "use WAGTAILEMBEDS_EMBEDLY_KEY instead.", - RemovedInWagtail14Warning) + if hasattr(settings, 'WAGTAILEMBEDS_EMBEDLY_KEY') or hasattr(settings, 'EMBEDLY_KEY'):: return embedly # Fall back to oembed From 8a0f6eab30205ca37b8aeae74be9ddaf3151634d Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Thu, 8 Oct 2015 09:35:21 +0100 Subject: [PATCH 3/3] Changelog/release note and contributor for #1799 --- CHANGELOG.txt | 1 + CONTRIBUTORS.rst | 1 + docs/releases/1.2.rst | 1 + 3 files changed, 3 insertions(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 6fabb60147..32f980e816 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -13,6 +13,7 @@ Changelog * page_published signal now called with the revision object that was published (Josh Barr) * Added an overrideable favicon to the admin interface * Added spinner animations to long-running form submissions + * The EMBEDLY_KEY setting has been renamed to WAGTAILEMBEDS_EMBEDLY_KEY (Anurag Sharma) * Fix: Deleting a page permission from the groups admin UI does not immediately submit the form * Fix: Wagtail userbar is shown on pages that do not pass a `page` variable to the template (e.g. because they override the `serve` method) * Fix: request.site now set correctly on page preview when the page is not in the default site diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index cf0722ea86..bb1dbb60f2 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -66,6 +66,7 @@ Contributors * Michael Cordover * Timothy Allen * Rob Shelton +* Anurag Sharma Translators diff --git a/docs/releases/1.2.rst b/docs/releases/1.2.rst index 53f40f9078..67d0d4a96e 100644 --- a/docs/releases/1.2.rst +++ b/docs/releases/1.2.rst @@ -29,6 +29,7 @@ Minor features * page_published signal now called with the revision object that was published * Added a favicon to the admin interface, customisable by overriding the ``branding_favicon`` block (see :ref:`custom_branding`). * Added spinner animations to long-running form submissions + * The EMBEDLY_KEY setting has been renamed to WAGTAILEMBEDS_EMBEDLY_KEY Bug fixes ~~~~~~~~~