wagtail-nest / wagtail-personalisation

Rule-based personalisation for Wagtail CMS
http://wagxperience.io/
MIT License
120 stars 34 forks source link

New get_context function in 2.15 introduces an admin home page incompatibility between versions < 2.15 and > 2.15 #228

Closed awhileback closed 2 years ago

awhileback commented 2 years ago

In upgrading from wagtail 2.14 to 2.15 I found that the admin home page wouldn't work after the upgrade, this seems to be the fault of a get_context override in wagtail_hooks on wagtail-personalisation for the page summary counts.

Django template error output:

Reverse for 'wagtailadmin_explore' with arguments '('',)' not found. 
1 pattern(s) tried: ['admin\\/pages\\/(?P<parent_page_id>[0-9]+)\\/$']

Django template error output detail:

context_data {}
message 
('Summary item '
 '<wagtail_personalisation.wagtail_hooks.CorrectedPagesSummaryItem object at '
 '0x7fcab9180390> should provide get_context_data(self, parent_context) rather '
 'than get_context(self). See '
 'https://docs.wagtail.io/en/stable/releases/2.15.html#template-components-2-15')
parent_context  
[{'True': True, 'False': False, 'None': None}, {'summary_items': [<wagtail_personalisation.wagtail_hooks.CorrectedPagesSummaryItem object at 0x7fcab9180390>,
...

The commit to my fork below fixes it for 2.15, but I don't know how you guys want to handle this since you'll need a conditional check on which version is installed to determine which method to call, or alternatively have both a get_context method and a get_context_data method somehow, both of which seem kinda sloppy so I didn't go any further toward a PR.

https://github.com/awhileback/wagtail-personalisation/commit/b84b5f9f9e29b8c6efa60b4002af8d8529565a5e