1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Converted nested serializers to HyperlinkedModelSerializer

This commit is contained in:
Jeremy Stretch
2017-01-27 12:22:29 -05:00
parent ddc2c8d110
commit fa900d5dbb
9 changed files with 273 additions and 245 deletions

View File

@ -33,10 +33,12 @@ class CustomFieldModelViewSet(ModelViewSet):
custom_field_choices[cfc.id] = cfc.value
custom_field_choices = custom_field_choices
return {
context = super(CustomFieldModelViewSet, self).get_serializer_context()
context.update({
'custom_fields': custom_fields,
'custom_field_choices': custom_field_choices,
}
})
return context
def get_queryset(self):
# Prefetch custom field values
@ -55,8 +57,11 @@ class GraphListView(generics.ListAPIView):
GRAPH_TYPE_PROVIDER: Provider,
GRAPH_TYPE_SITE: Site,
}
obj = get_object_or_404(cls[self.kwargs.get('type')], pk=self.kwargs['pk'])
context = super(GraphListView, self).get_serializer_context()
context.update({'graphed_object': get_object_or_404(cls[self.kwargs.get('type')], pk=self.kwargs['pk'])})
context.update({
'graphed_object': obj,
})
return context
def get_queryset(self):