From cade0638b1047f331d3d842f5a0cd893e08bb6f8 Mon Sep 17 00:00:00 2001 From: Andy Babic Date: Wed, 19 Jun 2019 09:08:26 +0100 Subject: [PATCH] More fixes --- wagtailmenus/api/v1/renderers.py | 2 +- wagtailmenus/api/v1/serializers/menu.py | 2 +- wagtailmenus/api/v1/views.py | 14 ++++++-------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/wagtailmenus/api/v1/renderers.py b/wagtailmenus/api/v1/renderers.py index d6b97c9f5..5fac3726a 100644 --- a/wagtailmenus/api/v1/renderers.py +++ b/wagtailmenus/api/v1/renderers.py @@ -15,7 +15,7 @@ def get_context(self, data, accepted_media_type, renderer_context): return context def get_argument_form(self, data, view, request): - form = view.get_argument_form(request) + form = view.get_form(request) template = loader.get_template(self.argument_form_template) context = {'elements': [form.to_html(request)]} return template.render(context) diff --git a/wagtailmenus/api/v1/serializers/menu.py b/wagtailmenus/api/v1/serializers/menu.py index f29b72a31..088d430a5 100644 --- a/wagtailmenus/api/v1/serializers/menu.py +++ b/wagtailmenus/api/v1/serializers/menu.py @@ -185,7 +185,7 @@ def get_section_root_serializer_fields(self, instance): return self.section_root_serializer_fields def get_section_root_serializer_init_kwargs(self, instance): - return self.section_root_field_init_kwargs + return self.section_root_serializer_init_kwargs def get_items_serializer_class(self, instance): class SectionMenuItemSerializer(RecursiveMenuItemSerializer): diff --git a/wagtailmenus/api/v1/views.py b/wagtailmenus/api/v1/views.py index 7f801e1cb..4d3576422 100644 --- a/wagtailmenus/api/v1/views.py +++ b/wagtailmenus/api/v1/views.py @@ -106,19 +106,17 @@ def get_form(self): init_kwargs = self.get_form_init_kwargs() return form_class(**init_kwargs) - def get_serializer(self, instance, **kwargs): + def get_serializer(self, menu_instance): serializer_class = self.get_serializer_class() - context = self.get_serializer_context(**kwargs) - return serializer_class(instance=instance, context=context) + context = self.get_serializer_context() + return serializer_class(menu_instance, context=context) - def get_serializer_context(self, **kwargs): - context = { + def get_serializer_context(self): + return { 'request': self.request, 'format': self.format_kwarg, 'view': self, } - context.update(kwargs) - return context def get(self, request, *args, **kwargs): # seen_types is a mapping of type name strings @@ -141,7 +139,7 @@ def get(self, request, *args, **kwargs): menu_instance = self.get_menu_instance(request, form) # Create a serializer for this menu instance - menu_serializer = self.get_serializer(menu_instance, request, **kwargs) + menu_serializer = self.get_serializer(menu_instance) response_data = menu_serializer.data return Response(response_data)