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

add support for regions and vms

This commit is contained in:
John Anderson
2020-10-23 01:18:04 -04:00
parent 3ba18633de
commit 22d2289ed2
9 changed files with 87 additions and 49 deletions

View File

@ -64,6 +64,21 @@ class VirtualMachineViewSet(CustomFieldModelViewSet):
)
filterset_class = filters.VirtualMachineFilterSet
def get_queryset(self):
"""
Build the proper queryset based on the request context
If the `brief` query param equates to True or the `exclude` query param
includes `config_context` as a value, return the base queryset.
Else, return the queryset annotated with config context data
"""
request = self.get_serializer_context()['request']
if request.query_params.get('brief') or 'config_context' in request.query_params.get('exclude', []):
return self.queryset
return self.queryset.annotate_config_context_data()
def get_serializer_class(self):
"""
Select the specific serializer based on the request context.