Skip to content

Releases: jazzband/wagtailmenus

v2.2.3

21 Jul 11:17
Compare
Choose a tag to compare

This is a minor maintenance / bug fix release.

  • Fixed a bug that would result in {% sub_menu %} being called recursively (until raising a "maximum recursion depth exceeded" exception) if a 'repeated menu item' was added at anything past the 2nd level. Thanks to @pyMan for raising/investigating.

v.2.1.4

21 Jul 11:16
Compare
Choose a tag to compare

This is a minor maintenance / bug fix release.

  • Fixed a bug that would result in {% sub_menu %} being called recursively (until raising a "maximum recursion depth exceeded" exception) if a 'repeated menu item' was added at anything past the 2nd level. Thanks to @pyMan for raising/investigating.

v2.3.1

01 Jul 15:37
Compare
Choose a tag to compare

Minor maintenance release

  • Code example formatting fixes, and better use of headings in README.md.
  • Added 'on_delete=models.CASCADE' to all relationship fields on models where
    no 'on_delete' behaviour was previously set (Django 2.0 compatibility).
  • Marked a missing string for translation (@einsfr)
  • Updated translations for Lithuanian, Portuguese (Brazil), and Russian.
    Many thanks to @mamorim, @treavis and @einsfr!

v.2.3.0

21 Jun 22:03
Compare
Choose a tag to compare

New / updated features

  • Added an 'AbstractLinkPage' model to wagtailmenus.models that can be easily sub-classed and used in projects to create 'link pages' that act in a similar fashion to menu items when appearing in menus, but can be placed in any part of the page tree. Find out more about this feature
  • Most of the functionality from MenuPage model has been abstracted out to a MenuPageMixin model, that can more easily be mixed in to existing page type models.
  • The 'modify_submenu_items', 'has_submenu_items' and 'get_repeated_menu_item' methods on MenuPageMixin / MenuPage have been updated to accept a new request keyword argument, which is used to pass in the current HttpRequest that the menu is being rendered for. See below for more details.
  • Added the WAGTAILMENUS_SECTION_MENU_CLASS_PATH setting, which can be used to override the Menu class used when using the {% section_menu %} tag.
  • Added the WAGTAILMENUS_CHILDREN_MENU_CLASS_PATH setting, which can be used to override the Menu class used when using the {% children_menu %} tag.
  • All Menu classes are now 'request aware', meaning self.request will return the current HttpRequest object within most methods (the menu tags set the value using a new set_request method, immediately after initialisation)
  • Added a get_base_page_queryset() method to all Menu classes, that can be overridden to change the base QuerySet used when identifying pages to be included in a menu when rendering. For example developers could use self.request.user to only ever include pages that the current user has some permissions for.
  • Added Russian translations (submitted by Alex einsfr).

Under the hood

  • Added wagtail 1.10 and django 1.11 test environments to tox
  • Renamed test_frontend.py to test_menu_rendering.py
  • In situations where request.site hasn't been set by wagtail's SiteMiddleware, the wagtailmenus context processor will now use the default site to generate menus with.
  • Updated AbstractMenuItem.clean() to only ever return field-specific validation errors, because Wagtail doesn't render non-field errors for related models added to the editor interface using InlinePanel.
  • Refactored runtest.py to accept a deprecation argument that can be used to surface deprecation warnings that arise when running tests.

Upgrade considerations

Deprecated behavior

Several methods on the MenuPage model have been updated to accept a request parameter. If you're upgrading to version 2.3.0 from a previous version, it's not necessary to make any changes immediately in order for wagtailmenus to work, but if you're using the MenuPage class in your project, and are overridingmodify_submenu_items(), has_submenu_items()
or get_repeated_menu_item(), you should think about updating the signatures of those methods to accept the new argument and pass it through when calling super(). See the following code for an example:

from wagtailmenus.models import MenuPage


class ContactPage(MenuPage):
    ...

    def modify_submenu_items(
        self, menu_items, current_page, current_ancestor_ids, 
        current_site, allow_repeating_parents, apply_active_classes,
        original_menu_tag, menu_instance, request
    ):
        # Apply default modifications first of all
        menu_items = super(ContactPage, self).modify_submenu_items(
            menu_items, current_page, current_ancestor_ids, current_site, allow_repeating_parents, apply_active_classes, original_menu_tag,
            menu_instance, request)
        """
        If rendering a 'main_menu', add some additional menu items to the end
        of the list that link to various anchored sections on the same page
        """
        if original_menu_tag == 'main_menu':
            base_url = self.relative_url(current_site)
            """
            Additional menu items can be objects with the necessary attributes,
            or simple dictionaries. `href` is used for the link URL, and `text`
            is the text displayed for each link. Below, I've also used
            `active_class` to add some additional CSS classes to these items,
            so that I can target them with additional CSS  
            """
            menu_items.extend((
                {
                    'text': 'Get support',
                    'href': base_url + '#support',
                    'active_class': 'support',
                },
                {
                    'text': 'Speak to someone',
                    'href': base_url + '#call',
                    'active_class': 'call',
                },
                {
                    'text': 'Map & directions',
                    'href': base_url + '#map',
                    'active_class': 'map',
                },
            ))
        return menu_items

    def has_submenu_items(
    	self, current_page, allow_repeating_parents, original_menu_tag, 
    	menu_instance, request
    ):
        """
        Because `modify_submenu_items` is being used to add additional menu
        items, we need to indicate in menu templates that `ContactPage` objects
        do have submenu items in main menus, even if they don't have children
        pages.
        """
        if original_menu_tag == 'main_menu':
            return True
        return super(ContactPage, self).has_submenu_items(
            current_page, allow_repeating_parents, original_menu_tag,
            menu_instance, request)

If you choose not to update your versions of those methods to accept the request keyword argument, you will continue to see deprecation warnings until version 2.5.0, when it will be a requirement, and your existing code will no longer work.

v.2.2.2

27 Mar 21:54
Compare
Choose a tag to compare

This is just a minor release, so no feature changes or backwards-compatibility issues to worry about

What's changed?

  • Got the project set up in Transifex (finally) https://www.transifex.com/rkhleics/wagtailmenus/
  • Updated translatable strings throughout the project to use named variable substitution, and unmarked a few exception messages.
  • Added Lithuanian translations (submitted by Matas Dailyda).
  • Update codebase to better handle situations where request isn't available in the context, or request.site hasn't been set.

v2.2.1

06 Mar 11:01
Compare
Choose a tag to compare

This is just a minor release to addresses a few 'under the hood' things, and shouldn't introduce any backwards-incompatible changes.

What's changed?

  • Updated travis/tox test settings to test against Wagtail 1.9 & Django 1.10.
  • Removed a couple of less useful travis/tox environment tests to help with test speed.
  • Made use of 'extras_require' in setup.py to replace multiple requirements files.
  • Optimised the app_settings module so that we can ditch the questionably stuff
    we're doing with global value manipulation on app load (inspired by django-allauth).
  • Added new semantic version solution to the project (inspired by wagtail)

v2.2.0

20 Feb 13:39
Compare
Choose a tag to compare

New / updated features

  • Wagtailmenus now makes use of django's built-in django.template.loader.select_template() method
    to provide a more intuitive way for developers to override templates for specific menus without having to explicitly specify alternative templates via settings or via the template and sub_menu_template options for each menu tag. See the updated documentation for each tag for information about where wagtailmenus looks for templates.
  • Added the WAGTAILMENUS_SITE_SPECIFIC_TEMPLATE_DIRS setting to allow developers to choose to have wagtailmenus look in additional site-specific locations for templates to render menus.
  • Brazilian Portuguese language translations added by @MaxKurama.

Under the hood

  • Added a try/except to AbstractMenuItem.relative_url() so that errors aren't thrown when Page.relative_url() returns None for some reason.
  • Moved some methods out of template_tags/menu_tags.py into a new utils.py file to make menu_tags.py easier to read / manage.

Upgrade considerations

N/A

v2.1.3

20 Jan 13:59
Compare
Choose a tag to compare

This release fixes a bug in the section_menu tag when attempting to apply the correct active class to section_root when the modify_submenu_items() method has been overridden to return additional items without an active_class attribute (like in the example code in README)

v2.1.2

07 Jan 00:39
Compare
Choose a tag to compare

This release fixes a bug that was preventing reordered menu items from retaining their new order after saving. The Meta class on the new abstract models had knocked out the sort_order ordering from wagtail.wagtailcore.models.Orderable.

v2.1.1

02 Jan 15:06
Compare
Choose a tag to compare

New / updated features

  • Added official support for wagtail v1.8
  • Added WAGTAILMENUS_MAIN_MENU_MODEL and WAGTAILMENUS_FLAT_MENU_MODEL
    settings to allow the default main and flat menu models to be swapped out for
    custom models.
  • Added WAGTAILMENUS_MAIN_MENU_ITEMS_RELATED_NAME and
    WAGTAILMENUS_FLAT_MENU_ITEMS_RELATED_NAME settings to allow the default
    menu item models to be swapped out for custom models.
  • Added the WAGTAILMENUS_PAGE_FIELD_FOR_MENU_ITEM_TEXT setting to allow
    developers to specify a page attribute other than title to be used to
    populate the text attribute for menu items linking to pages.
  • Added german translation by Pierre (@bloodywing).

Under the hood

  • Split models.py into 3 logically-named files to make models easier to find.
  • Turned wagtailmenus.app_settings into a real settings module.

Upgrade considerations

N/A