diff --git a/CHANGELOG.txt b/CHANGELOG.txt index b36af8117..a307b340d 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -21,6 +21,7 @@ Changelog * Added `WAGTAILADMIN_RECENT_EDITS_LIMIT` setting to to define the number of your most recent edits on the dashboard (Maarten Kling) * Creating / editing users through the Wagtail admin no longer modifies the `is_staff` flag (Matt Westcott) * Added link to the full Elasticsearch setup documentation from the Performance page (Matt Westcott) + * Tag input fields now accept spaces in tags by default, and can be overridden with the `TAG_SPACES_ALLOWED` setting (Kees Hink, Alex Gleason) * Fix: Marked 'Date from' / 'Date to' strings in wagtailforms for translation (Vorlif) * Fix: "File" field label on image edit form is now translated (Stein Strindhaug) * Fix: Unreliable preview is now reliable by always opening in a new window (Kjartan Sverrisson) diff --git a/docs/advanced_topics/settings.rst b/docs/advanced_topics/settings.rst index 505160c50..55b65c893 100644 --- a/docs/advanced_topics/settings.rst +++ b/docs/advanced_topics/settings.rst @@ -327,6 +327,15 @@ Case-Insensitive Tags Tags are case-sensitive by default ('music' and 'Music' are treated as distinct tags). In many cases the reverse behaviour is preferable. +Multi-word tags +--------------- + +.. code-block:: python + + TAG_SPACES_ALLOWED = False + +Tags can only consist of a single word, no spaces allowed. The default setting is ``True`` (spaces in tags are allowed). + Unicode Page Slugs ------------------ diff --git a/docs/releases/1.10.rst b/docs/releases/1.10.rst index ad82fd491..47637d33d 100644 --- a/docs/releases/1.10.rst +++ b/docs/releases/1.10.rst @@ -28,6 +28,7 @@ Other features * Added support for displaying ``non_field_errors`` when validation fails in the page editor (Matt Westcott) * Added `WAGTAILADMIN_RECENT_EDITS_LIMIT` setting to to define the number of your most recent edits on the dashboard (Maarten Kling) * Added link to the full Elasticsearch setup documentation from the Performance page (Matt Westcott) + * Tag input fields now accept spaces in tags by default, and can be overridden with the ``TAG_SPACES_ALLOWED`` setting (Kees Hink, Alex Gleason) Bug fixes diff --git a/wagtail/wagtailadmin/static_src/wagtailadmin/js/core.js b/wagtail/wagtailadmin/static_src/wagtailadmin/js/core.js index 346c2072d..affe92606 100644 --- a/wagtail/wagtailadmin/static_src/wagtailadmin/js/core.js +++ b/wagtail/wagtailadmin/static_src/wagtailadmin/js/core.js @@ -21,7 +21,7 @@ function escapeHtml(text) { }); } -function initTagField(id, autocompleteUrl) { +function initTagField(id, autocompleteUrl, allowSpaces) { $('#' + id).tagit({ autocomplete: {source: autocompleteUrl}, preprocessTag: function(val) { @@ -32,7 +32,9 @@ function initTagField(id, autocompleteUrl) { } return val; - } + }, + + allowSpaces: allowSpaces }); } diff --git a/wagtail/wagtailadmin/widgets.py b/wagtail/wagtailadmin/widgets.py index dc2c0f2a7..332a8e9f3 100644 --- a/wagtail/wagtailadmin/widgets.py +++ b/wagtail/wagtailadmin/widgets.py @@ -4,6 +4,7 @@ import itertools import json from functools import total_ordering +from django.conf import settings from django.core.urlresolvers import reverse from django.forms import widgets from django.forms.utils import flatatt @@ -68,9 +69,11 @@ class AdminDateTimeInput(WidgetWithScript, widgets.DateTimeInput): class AdminTagWidget(WidgetWithScript, TagWidget): def render_js_init(self, id_, name, value): - return "initTagField({0}, {1});".format( + return "initTagField({0}, {1}, {2});".format( json.dumps(id_), - json.dumps(reverse('wagtailadmin_tag_autocomplete'))) + json.dumps(reverse('wagtailadmin_tag_autocomplete')), + 'true' if getattr(settings, 'TAG_SPACES_ALLOWED', True) else 'false', + ) class AdminChooser(WidgetWithScript, widgets.Input):