Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ababic committed Jun 19, 2019
1 parent 052536f commit d08866a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion wagtailmenus/api/v1/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion wagtailmenus/api/v1/serializers/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
14 changes: 6 additions & 8 deletions wagtailmenus/api/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit d08866a

Please sign in to comment.