diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 2e2977ab4..c60f672d2 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -34,6 +34,7 @@ Changelog * Fix: Storage backends that return raw ContentFile objects are now handled correctly when resizing images (@georgewhewell) * Fix: Punctuation characters are no longer stripped when performing search queries * Fix: When adding tags where there were none before, it is now possible to save a single tag with multiple words in it +* Fix: richtext template tag no longer raises TypeError if None is passed into it (Alejandro Varas) 0.8.4 (04.12.2014) ~~~~~~~~~~~~~~~~~~ diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index d0c34417c..44992e71a 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -42,6 +42,7 @@ Contributors * georgewhewell * Frank Wiles * Sebastian Spiegel +* Alejandro Varas Translators =========== diff --git a/docs/core_components/form_builder.rst b/docs/core_components/form_builder.rst index 65ed639bf..a98284d35 100644 --- a/docs/core_components/form_builder.rst +++ b/docs/core_components/form_builder.rst @@ -36,7 +36,7 @@ Within the models.py of one of your apps, create a model that extends wagtailfor FormPage.content_panels = [ FieldPanel('title', classname="full title"), FieldPanel('intro', classname="full"), - InlinePanel(FormPage, 'form_fields', label="Form fields"), + InlinePanel('form_fields', label="Form fields"), FieldPanel('thank_you_text', classname="full"), MultiFieldPanel([ FieldPanel('to_address', classname="full"), diff --git a/docs/core_components/pages/creating_pages.rst b/docs/core_components/pages/creating_pages.rst index 24e598549..61bcf712d 100644 --- a/docs/core_components/pages/creating_pages.rst +++ b/docs/core_components/pages/creating_pages.rst @@ -20,7 +20,6 @@ This example represents a typical blog post: from wagtail.wagtailcore.fields import RichTextField from wagtail.wagtailadmin.edit_handlers import FieldPanel from wagtail.wagtailimages.edit_handlers import ImageChooserPanel - from wagtail.wagtailimages.models import Image class BlogPage(Page): body = RichTextField() diff --git a/docs/core_components/pages/editing_api.rst b/docs/core_components/pages/editing_api.rst index 2087f8c87..7cf4a7054 100644 --- a/docs/core_components/pages/editing_api.rst +++ b/docs/core_components/pages/editing_api.rst @@ -31,7 +31,7 @@ There are four basic types of panels: ``MultiFieldPanel( children, heading="", classname=None )`` This panel condenses several ``FieldPanel`` s or choosers, from a list or tuple, under a single ``heading`` string. - ``InlinePanel( base_model, relation_name, panels=None, classname=None, label='', help_text='' )`` + ``InlinePanel( relation_name, panels=None, classname=None, label='', help_text='' )`` This panel allows for the creation of a "cluster" of related objects over a join to a separate model, such as a list of related links or slides to an image carousel. This is a very powerful, but tricky feature which will take some space to cover, so we'll skip over it for now. For a full explanation on the usage of ``InlinePanel``, see :ref:`inline_panels`. ``FieldRowPanel( children, classname=None)`` @@ -354,16 +354,20 @@ Let's look at the example of adding related links to a ``Page``-derived model. W BookPage.content_panels = [ # ... - InlinePanel( BookPage, 'related_links', label="Related Links" ), + InlinePanel( 'related_links', label="Related Links" ), ] The ``RelatedLink`` class is a vanilla Django abstract model. The ``BookPageRelatedLinks`` model extends it with capability for being ordered in the Wagtail interface via the ``Orderable`` class as well as adding a ``page`` property which links the model to the ``BookPage`` model we're adding the related links objects to. Finally, in the panel definitions for ``BookPage``, we'll add an ``InlinePanel`` to provide an interface for it all. Let's look again at the parameters that ``InlinePanel`` accepts: .. code-block:: python - InlinePanel( base_model, relation_name, panels=None, label='', help_text='' ) + InlinePanel( relation_name, panels=None, label='', help_text='' ) -``base_model`` is the model you're extending with the cluster. The ``relation_name`` is the ``related_name`` label given to the cluster's ``ParentalKey`` relation. You can add the ``panels`` manually or make them part of the cluster model. Finally, ``label`` and ``help_text`` provide a heading and caption, respectively, for the Wagtail editor. +The ``relation_name`` is the ``related_name`` label given to the cluster's ``ParentalKey`` relation. You can add the ``panels`` manually or make them part of the cluster model. Finally, ``label`` and ``help_text`` provide a heading and caption, respectively, for the Wagtail editor. + +.. versionchanged:: 0.9 + + In previous versions, it was necessary to pass the base model as the first parameter to ``InlinePanel``; this is no longer required. For another example of using model clusters, see :ref:`tagging` diff --git a/docs/core_components/snippets.rst b/docs/core_components/snippets.rst index 33d20bdc4..e323bdb68 100644 --- a/docs/core_components/snippets.rst +++ b/docs/core_components/snippets.rst @@ -151,7 +151,7 @@ To attach multiple adverts to a page, the ``SnippetChooserPanel`` can be placed ... BookPage.content_panels = [ - InlinePanel(BookPage, 'advert_placements', label="Adverts"), + InlinePanel('advert_placements', label="Adverts"), # ... ] diff --git a/docs/releases/0.8.5.rst b/docs/releases/0.8.5.rst index f75f93e60..482d660a0 100644 --- a/docs/releases/0.8.5.rst +++ b/docs/releases/0.8.5.rst @@ -20,3 +20,4 @@ Bug fixes * Storage backends that return raw ContentFile objects are now handled correctly when resizing images * Punctuation characters are no longer stripped when performing search queries * When adding tags where there were none before, it is now possible to save a single tag with multiple words in it + * ``richtext`` template tag no longer raises ``TypeError`` if ``None`` is passed into it diff --git a/docs/releases/0.9.rst b/docs/releases/0.9.rst index 981cd60d1..0101e0760 100644 --- a/docs/releases/0.9.rst +++ b/docs/releases/0.9.rst @@ -28,7 +28,7 @@ Minor features * Removed the need to add permission check on admin views (now automated) * Reversing `django.contrib.auth.admin.login` will no longer lead to Wagtails login view (making it easier to have front end views) * Added cache-control headers to all admin views. This allows Varnish/Squid/CDN to run on vanilla settings in front of a Wagtail site - * Added validation to prevent pages being crated with only whitespace characters in their title fields + * Added validation to prevent pages being created with only whitespace characters in their title fields * Page model fields without a FieldPanel are no longer displayed in the form * No longer need to specify the base model on InlinePanel definitions @@ -47,18 +47,51 @@ This release drops support for Django 1.6, Python 2.6/3.2 and Elasticsearch 0.90 If you are upgrading from Elasticsearch 0.90.x, you may also need to update the ``elasticsearch`` pip package to a version greater than ``1.0`` as well. +InlinePanel definitions no longer need to specify the base model +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +In previous versions of Wagtail, inline child blocks on a page or snippet were defined using a declaration like:: + + InlinePanel(HomePage, 'carousel_items', label="Carousel items") + +It is no longer necessary to pass the base model as a parameter, so this declaration should be changed to:: + + InlinePanel('carousel_items', label="Carousel items") + +The old format is now deprecated; all existing InlinePanel declarations should be updated to the new format. + Login/Password reset views renamed ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It was previously possible to reverse the Wagtail login using django.contrib.auth.views.login. -This is no longer possible. Update any references to `wagtailadmin_login`. +This is no longer possible. Update any references to ``wagtailadmin_login``. -Password reset view name has changed from `password_reset` to `wagtailadmin_password_reset`. +Password reset view name has changed from ``password_reset`` to ``wagtailadmin_password_reset``. -You no longer need `LOGIN_URL` and `LOGIN_REDIRECT_URL` to point to Wagtail admin. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +You no longer need ``LOGIN_URL`` and ``LOGIN_REDIRECT_URL`` to point to Wagtail admin. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Javascript includes in admin backend have been moved ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To improve compatibility with third-party form widgets, pages within the Wagtail admin backend now output their Javascript includes in the HTML header, rather than at the end of the page. If your project extends the admin backend (through the ``register_admin_menu_item`` hook, for example) you will need to ensure that all associated Javascript code runs correctly from the new location. In particular, any code that accesses HTML elements will need to be contained in an 'onload' handler (e.g. jQuery's ``$(document).ready()``). + +EditHandler internal API has changed +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +While it is not an official Wagtail API, it has been possible for Wagtail site implementers to define their own ``EditHandler`` subclasses for use in panel definitions, to customise the behaviour of the page / snippet editing forms. If you have made use of this facility, you will need to update your custom EditHandlers, as this mechanism has been refactored (to allow EditHandler classes to keep a persistent reference to their corresponding model). If you have only used Wagtail's built-in panel types (``FieldPanel``, ``InlinePanel``, ``PageChooserPanel`` and so on), you are unaffected by this change. + +Previously, functions like ``FieldPanel`` acted as 'factory' functions, where a call such as ``FieldPanel('title')`` constructed and returned an ``EditHandler`` subclass tailored to work on a 'title' field. These functions now return an object with a ``bind_to_model`` method instead; the EditHandler subclass can be obtained by calling this with the model class as a parameter. As a guide to updating your custom EditHandler code, you may wish to refer to `the relevant change to the Wagtail codebase `_. + +chooser_panel templates are obsolete +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If you have added your own custom admin views to the Wagtail admin (e.g. through the ``register_admin_urls`` hook), you may have used one of the following template includes to incorporate a chooser element for pages, documents, images or snippets into your forms: + +- ``wagtailadmin/edit_handlers/chooser_panel.html`` +- ``wagtailadmin/edit_handlers/page_chooser_panel.html`` +- ``wagtaildocs/edit_handlers/document_chooser_panel.html`` +- ``wagtailimages/edit_handlers/image_chooser_panel.html`` +- ``wagtailsnippets/edit_handlers/snippet_chooser_panel.html`` + +All of these templates are now deprecated. Wagtail now provides a set of Django form widgets for this purpose - ``AdminPageChooser``, ``AdminDocumentChooser``, ``AdminImageChooser`` and ``AdminSnippetChooser`` - which can be used in place of the ``HiddenInput`` widget that these form fields were previously using. The field can then be rendered using the regular ``wagtailadmin/shared/field.html`` or ``wagtailadmin/shared/field_as_li.html`` template. diff --git a/runtests.py b/runtests.py index 7961d2e19..a1925f907 100755 --- a/runtests.py +++ b/runtests.py @@ -15,6 +15,7 @@ os.environ['DJANGO_SETTINGS_MODULE'] = 'wagtail.tests.settings' def runtests(): # Don't ignore DeprecationWarnings warnings.simplefilter('default', DeprecationWarning) + warnings.simplefilter('default', PendingDeprecationWarning) argv = sys.argv[:1] + ['test'] + sys.argv[1:] try: diff --git a/wagtail/contrib/wagtailstyleguide/templates/wagtailstyleguide/base.html b/wagtail/contrib/wagtailstyleguide/templates/wagtailstyleguide/base.html index 358bc71bd..37247b81e 100644 --- a/wagtail/contrib/wagtailstyleguide/templates/wagtailstyleguide/base.html +++ b/wagtail/contrib/wagtailstyleguide/templates/wagtailstyleguide/base.html @@ -355,8 +355,6 @@ {% for field in example_form %} {% if field.name == 'file' %} {% include "wagtailimages/images/_file_field.html" %} - {% elif field.name == 'date' %} - {% include "wagtailadmin/shared/field_as_li.html" with input_classes="iconfield icon-date" %} {% else %} {% include "wagtailadmin/shared/field_as_li.html" %} {% endif %} @@ -365,13 +363,7 @@ -

TODO: Date picker

-

TODO: Time picker

-

TODO: Datetime picker

TODO: Rich text input

-

TODO: Page chooser

-

TODO: Image chooser

-

TODO: Document chooser

TODO: Snippet chooser

@@ -540,42 +532,43 @@ {% endblock %} {% block extra_js %} - + (function runprogress(){ + var to = setTimeout(function(){ + runprogress(); + clearTimeout(to); + var to2 = setTimeout(function(){ + $('#progress-example .bar').css('width', '20%'); + }, 2000); + }, 3000); + $('#progress-example .bar').css('width', '80%'); + })(); + }) + {% endblock %} \ No newline at end of file diff --git a/wagtail/contrib/wagtailstyleguide/views.py b/wagtail/contrib/wagtailstyleguide/views.py index 98112adcb..4b8139e6f 100644 --- a/wagtail/contrib/wagtailstyleguide/views.py +++ b/wagtail/contrib/wagtailstyleguide/views.py @@ -5,9 +5,21 @@ from wagtail.wagtailadmin import messages from django.contrib.auth.decorators import permission_required from wagtail.wagtailadmin.forms import SearchForm - +from wagtail.wagtailadmin.widgets import AdminPageChooser, AdminDateInput, AdminTimeInput, AdminDateTimeInput +from wagtail.wagtailimages.widgets import AdminImageChooser +from wagtail.wagtaildocs.widgets import AdminDocumentChooser class ExampleForm(forms.Form): + + def __init__(self, *args, **kwargs): + super(ExampleForm, self).__init__(*args, **kwargs) + self.fields['page_chooser'].widget = AdminPageChooser() + self.fields['image_chooser'].widget = AdminImageChooser() + self.fields['document_chooser'].widget = AdminDocumentChooser() + self.fields['date'].widget = AdminDateInput() + self.fields['time'].widget = AdminTimeInput() + self.fields['datetime'].widget = AdminDateTimeInput() + CHOICES = ( ('choice1', 'choice 1'), ('choice2', 'choice 2'), @@ -18,8 +30,13 @@ class ExampleForm(forms.Form): email = forms.EmailField(max_length=254) date = forms.DateField() time = forms.TimeField() + datetime = forms.DateTimeField() select = forms.ChoiceField(choices=CHOICES) boolean = forms.BooleanField(required=False) + page_chooser = forms.BooleanField(required=True) + image_chooser = forms.BooleanField(required=True) + document_chooser = forms.BooleanField(required=True) + @permission_required('wagtailadmin.access_admin') diff --git a/wagtail/tests/models.py b/wagtail/tests/models.py index 2b20d7a7c..c419de7c7 100644 --- a/wagtail/tests/models.py +++ b/wagtail/tests/models.py @@ -247,10 +247,10 @@ EventPage.content_panels = [ FieldPanel('audience'), FieldPanel('cost'), FieldPanel('signup_link'), - InlinePanel(EventPage, 'carousel_items', label="Carousel items"), + InlinePanel('carousel_items', label="Carousel items"), FieldPanel('body', classname="full"), - InlinePanel(EventPage, 'speakers', label="Speakers"), - InlinePanel(EventPage, 'related_links', label="Related links"), + InlinePanel('speakers', label="Speakers"), + InlinePanel('related_links', label="Related links"), ] EventPage.promote_panels = [ @@ -329,7 +329,7 @@ class FormPage(AbstractEmailForm): FormPage.content_panels = [ FieldPanel('title', classname="full title"), - InlinePanel(FormPage, 'form_fields', label="Form fields"), + InlinePanel('form_fields', label="Form fields"), MultiFieldPanel([ FieldPanel('to_address', classname="full"), FieldPanel('from_address', classname="full"), @@ -392,7 +392,7 @@ class StandardIndex(Page): StandardIndex.content_panels = [ FieldPanel('title', classname="full title"), - InlinePanel(StandardIndex, 'advert_placements', label="Adverts"), + InlinePanel('advert_placements', label="Adverts"), ] diff --git a/wagtail/tests/utils.py b/wagtail/tests/utils.py index fd155e6b4..1abfb0116 100644 --- a/wagtail/tests/utils.py +++ b/wagtail/tests/utils.py @@ -1,5 +1,6 @@ from contextlib import contextmanager import warnings +import sys from django.contrib.auth import get_user_model from django.utils import six @@ -24,7 +25,22 @@ class WagtailTestUtils(object): with warnings.catch_warnings(record=True) as warning_list: # catch all warnings yield - # rethrow all warnings that were not DeprecationWarnings + # rethrow all warnings that were not DeprecationWarnings or PendingDeprecationWarnings for w in warning_list: - if not issubclass(w.category, DeprecationWarning): + if not issubclass(w.category, (DeprecationWarning, PendingDeprecationWarning)): warnings.showwarning(message=w.message, category=w.category, filename=w.filename, lineno=w.lineno, file=w.file, line=w.line) + + # borrowed from https://github.com/django/django/commit/9f427617e4559012e1c2fd8fce46cbe225d8515d + @staticmethod + 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 list(sys.modules.values()): + if hasattr(mod, key): + getattr(mod, key).clear() diff --git a/wagtail/utils/widgets.py b/wagtail/utils/widgets.py index 8ae51ce6b..6c232bb64 100644 --- a/wagtail/utils/widgets.py +++ b/wagtail/utils/widgets.py @@ -5,16 +5,22 @@ from django.utils.safestring import mark_safe class WidgetWithScript(Widget): - def render(self, name, value, attrs=None): - widget = super(WidgetWithScript, self).render(name, value, attrs) + def render_html(self, name, value, attrs): + """Render the HTML (non-JS) portion of the field markup""" + return super(WidgetWithScript, self).render(name, value, attrs) - final_attrs = self.build_attrs(attrs, name=name) - id_ = final_attrs.get('id', None) - if id_ is None: - return widget + def render(self, name, value, attrs=None): + # no point trying to come up with sensible semantics for when 'id' is missing from attrs, + # so let's make sure it fails early in the process + try: + id_ = attrs['id'] + except (KeyError, TypeError): + raise TypeError("WidgetWithScript cannot be rendered without an 'id' attribute") + + widget_html = self.render_html(name, value, attrs) js = self.render_js_init(id_, name, value) - out = '{0}'.format(widget, js) + out = '{0}'.format(widget_html, js) return mark_safe(out) def render_js_init(self, id_, name, value): diff --git a/wagtail/wagtailadmin/blocks.py b/wagtail/wagtailadmin/blocks.py index 57673a070..fa2b779bc 100644 --- a/wagtail/wagtailadmin/blocks.py +++ b/wagtail/wagtailadmin/blocks.py @@ -6,7 +6,7 @@ from __future__ import unicode_literals import re import collections -from django.core.exceptions import ValidationError +from django.core.exceptions import ValidationError, ImproperlyConfigured from django.utils.html import format_html, format_html_join from django.utils.safestring import mark_safe from django.utils.text import capfirst @@ -14,7 +14,7 @@ from django.utils.encoding import force_text, python_2_unicode_compatible from django.utils.deconstruct import deconstructible from django.utils.functional import cached_property from django.template.loader import render_to_string -from django.forms import Media, CharField +from django.forms import Media, CharField, ModelChoiceField from django.forms.utils import ErrorList import six @@ -277,9 +277,18 @@ class FieldBlock(Block): class Meta: default = None - def __init__(self, field, **kwargs): + def __init__(self, field=None, **kwargs): super(FieldBlock, self).__init__(**kwargs) - self.field = field + self._field = field + + @cached_property + def field(self): + # Sometimes the field object needs to be constructed lazily - for example, ModelChoiceFields + # cannot be defined until models have been loaded. In those cases, we can leave field unspecified + # in the constructor, and override this method instead. + if self._field is None: + raise ImproperlyConfigured("FieldBlock was not passed a field object") + return self._field def render_form(self, value, prefix='', error=None): widget = self.field.widget @@ -340,6 +349,13 @@ class RichTextBlock(FieldBlock): def render_basic(self, value): return mark_safe('
' + expand_db_html(value) + '
') +class PageChooserBlock(FieldBlock): + @cached_property + def field(self): + from wagtail.wagtailcore.models import Page # TODO: allow limiting to specific page types + from wagtail.wagtailadmin.widgets import AdminPageChooser + return ModelChoiceField(queryset=Page.objects.all(), widget=AdminPageChooser) + # ======= # Chooser # ======= diff --git a/wagtail/wagtailadmin/edit_handlers.py b/wagtail/wagtailadmin/edit_handlers.py index 9b1a6f8b9..ec25e785e 100644 --- a/wagtail/wagtailadmin/edit_handlers.py +++ b/wagtail/wagtailadmin/edit_handlers.py @@ -1,6 +1,7 @@ from __future__ import unicode_literals import copy +import warnings from six import text_type @@ -21,6 +22,7 @@ from taggit.managers import TaggableManager from wagtail.wagtailadmin import widgets from wagtail.wagtailcore.models import Page from wagtail.wagtailcore.utils import camelcase_to_underscore, resolve_model_string +from wagtail.utils.deprecation import RemovedInWagtail11Warning FORM_FIELD_OVERRIDES = { @@ -431,18 +433,16 @@ class BaseFieldPanel(EditHandler): def render_as_object(self): return mark_safe(render_to_string(self.object_template, { 'self': self, - 'field_content': self.render_as_field(show_help_text=False), + 'field_content': self.render_as_field(), })) field_template = "wagtailadmin/edit_handlers/field_panel_field.html" - def render_as_field(self, show_help_text=True, extra_context={}): + def render_as_field(self): context = { 'field': self.bound_field, 'field_type': self.field_type(), - 'show_help_text': show_help_text, } - context.update(extra_context) return mark_safe(render_to_string(self.field_template, context)) @classmethod @@ -491,7 +491,7 @@ class BaseChooserPanel(BaseFieldPanel): a hidden foreign key input. Subclasses provide: - * field_template + * field_template (only required if the default template of field_panel_field.html is not usable) * object_type_name - something like 'image' which will be used as the var name for the object instance in the field_template """ @@ -505,20 +505,17 @@ class BaseChooserPanel(BaseFieldPanel): # like every other unpopulated field type. Yay consistency! return None - def render_as_field(self, show_help_text=True, extra_context={}): + def render_as_field(self): instance_obj = self.get_chosen_item() context = { 'field': self.bound_field, self.object_type_name: instance_obj, - 'is_chosen': bool(instance_obj), - 'show_help_text': show_help_text, + 'is_chosen': bool(instance_obj), # DEPRECATED - passed to templates for backwards compatibility only } - context.update(extra_context) return mark_safe(render_to_string(self.field_template, context)) class BasePageChooserPanel(BaseChooserPanel): - field_template = "wagtailadmin/edit_handlers/page_chooser_panel.html" object_type_name = "page" _target_content_type = None @@ -548,14 +545,6 @@ class BasePageChooserPanel(BaseChooserPanel): return cls._target_content_type - def render_as_field(self, show_help_text=True, extra_context={}): - context = { - 'choose_another_text_str': ugettext_lazy("Choose another page"), - 'choose_one_text_str': ugettext_lazy("Choose a page"), - } - context.update(extra_context) - return super(BasePageChooserPanel, self).render_as_field(show_help_text, context) - class PageChooserPanel(object): def __init__(self, field_name, page_type=None): @@ -651,13 +640,29 @@ class BaseInlinePanel(EditHandler): class InlinePanel(object): - def __init__(self, base_model, relation_name, panels=None, label='', help_text=''): - # the base_model param is now redundant; we set up relations based on the model passed to + def __init__(self, *args, **kwargs): + # prior to Wagtail 0.9, InlinePanel required two params, base_model and relation_name. + # base_model is no longer required; we set up relations based on the model passed to # bind_to_model instead - self.relation_name = relation_name - self.panels = panels - self.label = label - self.help_text = help_text + if len(args) == 1: # new-style: InlinePanel(relation_name) + self.relation_name = args[0] + elif len(args) == 2: # old-style: InlinePanel(base_model, relation_name) + self.relation_name = args[1] + + warnings.warn( + "InlinePanel no longer needs to be passed a model parameter. " + "InlinePanel({classname}, '{relname}') should be changed to InlinePanel('{relname}')".format( + classname=args[0].__name__, relname=self.relation_name + ), RemovedInWagtail11Warning, stacklevel=2) + else: + raise TypeError("InlinePanel() takes exactly 1 argument (%d given)" % len(args)) + + self.panels = kwargs.pop('panels', None) + self.label = kwargs.pop('label', '') + self.help_text = kwargs.pop('help_text', '') + + if kwargs: + raise TypeError("InlinePanel got an unexpected keyword argument '%s'" % kwargs.keys()[0]) def bind_to_model(self, model): return type(str('_InlinePanel'), (BaseInlinePanel,), { diff --git a/wagtail/wagtailadmin/menu.py b/wagtail/wagtailadmin/menu.py index df8bf7637..5fa4ff7cf 100644 --- a/wagtail/wagtailadmin/menu.py +++ b/wagtail/wagtailadmin/menu.py @@ -2,13 +2,8 @@ from __future__ import unicode_literals from six import text_type, with_metaclass -try: - # renamed util -> utils in Django 1.7; try the new name first - from django.forms.utils import flatatt -except ImportError: - from django.forms.util import flatatt - from django.forms import MediaDefiningClass, Media +from django.forms.utils import flatatt from django.utils.text import slugify from django.utils.html import format_html from django.utils.safestring import mark_safe diff --git a/wagtail/wagtailadmin/static/wagtailadmin/scss/components/forms.scss b/wagtail/wagtailadmin/static/wagtailadmin/scss/components/forms.scss index daee85da6..0df7d10c7 100644 --- a/wagtail/wagtailadmin/static/wagtailadmin/scss/components/forms.scss +++ b/wagtail/wagtailadmin/static/wagtailadmin/scss/components/forms.scss @@ -727,6 +727,9 @@ ul.tagit input[type="text"]{ ul.tagit li.tagit-choice-editable{ padding:0 23px 0 0 !important; /* having to use important, FML*/ } +.ui-front{ /* provided by jqueryui but not high enough an index */ + z-index:1000; +} .tagit-close{ .ui-icon-close{ diff --git a/wagtail/wagtailadmin/static/wagtailadmin/scss/components/listing.scss b/wagtail/wagtailadmin/static/wagtailadmin/scss/components/listing.scss index 10b4bf7eb..e7645b5bb 100644 --- a/wagtail/wagtailadmin/static/wagtailadmin/scss/components/listing.scss +++ b/wagtail/wagtailadmin/static/wagtailadmin/scss/components/listing.scss @@ -199,7 +199,6 @@ ul.listing{ color:$color-teal; border-color:$color-grey-3; background:white; - font-size:0.84em; /* 0.01em difference to regular small buttons */ &:hover{ border-color:$color-teal; diff --git a/wagtail/wagtailadmin/static/wagtailadmin/scss/components/main-nav.scss b/wagtail/wagtailadmin/static/wagtailadmin/scss/components/main-nav.scss index a1e3265d2..40e227914 100644 --- a/wagtail/wagtailadmin/static/wagtailadmin/scss/components/main-nav.scss +++ b/wagtail/wagtailadmin/static/wagtailadmin/scss/components/main-nav.scss @@ -126,7 +126,7 @@ $submenu-color:darken($color-grey-1, 5%); .menu-item a{ white-space:normal; - padding: 0.9em 0 0.9em 4.5em; + padding: 0.9em 1.7em 0.9em 4.5em; &:before{ margin-left:-1.5em; diff --git a/wagtail/wagtailadmin/templates/wagtailadmin/edit_handlers/chooser_panel.html b/wagtail/wagtailadmin/templates/wagtailadmin/edit_handlers/chooser_panel.html index bf583c1dd..5413952d1 100644 --- a/wagtail/wagtailadmin/templates/wagtailadmin/edit_handlers/chooser_panel.html +++ b/wagtail/wagtailadmin/templates/wagtailadmin/edit_handlers/chooser_panel.html @@ -1,6 +1,12 @@ {% extends "wagtailadmin/shared/field.html" %} {% load i18n %} {% comment %} + ------ + DEPRECATED - provided for backwards compatibility with custom (third-party) chooser panels + created prior to Wagtail 0.9. New choosers should subclass wagtail.wagtailadmin.widgets.AdminChooser, + with a template that extends wagtailadmin/widgets/chooser.html. + ------ + Either the chosen or unchosen div will be shown, depending on the presence of the 'blank' class on the container. @@ -10,21 +16,21 @@ {% block form_field %} -
+
{% block chosen_state_view %}{% endblock %}
{% if not field.field.required %} - + {% endif %} - +
- +
diff --git a/wagtail/wagtailadmin/templates/wagtailadmin/edit_handlers/page_chooser_panel.html b/wagtail/wagtailadmin/templates/wagtailadmin/edit_handlers/page_chooser_panel.html index fbca951ca..165bca017 100644 --- a/wagtail/wagtailadmin/templates/wagtailadmin/edit_handlers/page_chooser_panel.html +++ b/wagtail/wagtailadmin/templates/wagtailadmin/edit_handlers/page_chooser_panel.html @@ -1,8 +1,2 @@ -{% extends "wagtailadmin/edit_handlers/chooser_panel.html" %} - -{% block chosen_state_view %} - {{ page.title }} -{% endblock %} - -{% block choose_another_button_label %}{{ choose_another_text_str }}{% endblock %} -{% block choose_button_label %}{{ choose_one_text_str }}{% endblock %} +{# Page chooser is now implemented as an entirely standard form widget - page_chooser_panel.html is redundant #} +{% include "wagtailadmin/shared/field.html" %} diff --git a/wagtail/wagtailadmin/templates/wagtailadmin/pages/copy.html b/wagtail/wagtailadmin/templates/wagtailadmin/pages/copy.html index ef155ef9a..b0ccf3397 100644 --- a/wagtail/wagtailadmin/templates/wagtailadmin/pages/copy.html +++ b/wagtail/wagtailadmin/templates/wagtailadmin/pages/copy.html @@ -13,12 +13,7 @@