From 16ea847acab351af0bfbd7cd5c961efefaf99db7 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Tue, 28 Jun 2022 23:09:47 +0100 Subject: [PATCH] Split out a method for getting json_data to pass to chooser view --- wagtail/admin/views/generic/chooser.py | 9 ++++++--- wagtail/documents/views/chooser.py | 11 +++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/wagtail/admin/views/generic/chooser.py b/wagtail/admin/views/generic/chooser.py index 7b05dbe0a1..ed8f4a453f 100644 --- a/wagtail/admin/views/generic/chooser.py +++ b/wagtail/admin/views/generic/chooser.py @@ -244,6 +244,11 @@ class ChooseViewMixin: return context + def get_response_json_data(self): + return { + "step": "choose", + } + # Return the choose view as a ModalWorkflow response def render_to_response(self): return render_modal_workflow( @@ -251,9 +256,7 @@ class ChooseViewMixin: self.template_name, None, self.get_context_data(), - json_data={ - "step": "choose", - }, + json_data=self.get_response_json_data(), ) diff --git a/wagtail/documents/views/chooser.py b/wagtail/documents/views/chooser.py index a568f1a9e7..c6b9a33501 100644 --- a/wagtail/documents/views/chooser.py +++ b/wagtail/documents/views/chooser.py @@ -220,16 +220,19 @@ class DocumentChooseViewMixin: ) return context + def get_response_json_data(self): + return { + "step": "choose", + "tag_autocomplete_url": reverse("wagtailadmin_tag_autocomplete"), + } + def render_to_response(self): return render_modal_workflow( self.request, self.template_name, None, self.get_context_data(), - json_data={ - "step": "choose", - "tag_autocomplete_url": reverse("wagtailadmin_tag_autocomplete"), - }, + json_data=self.get_response_json_data(), )