Fixes #772: Fix TypeError in API RackUnitListView when no device is excluded

This commit is contained in:
Jeremy Stretch 2017-01-04 10:58:11 -05:00
parent 52567c4ade
commit 0d4b2a6e92

View File

@ -118,11 +118,13 @@ class RackUnitListView(APIView):
rack = get_object_or_404(Rack, pk=pk) rack = get_object_or_404(Rack, pk=pk)
face = request.GET.get('face', 0) face = request.GET.get('face', 0)
try: exclude_pk = request.GET.get('exclude', None)
exclude = int(request.GET.get('exclude', None)) if exclude_pk is not None:
except ValueError: try:
exclude = None exclude_pk = int(exclude_pk)
elevation = rack.get_rack_units(face, exclude) except ValueError:
exclude_pk = None
elevation = rack.get_rack_units(face, exclude_pk)
# Serialize Devices within the rack elevation # Serialize Devices within the rack elevation
for u in elevation: for u in elevation: