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

First batch of DCIM API tests

This commit is contained in:
Jeremy Stretch
2017-03-16 16:50:18 -04:00
parent bbc355df07
commit f33269e50b
5 changed files with 1086 additions and 666 deletions

View File

@@ -62,7 +62,14 @@ class ChoiceFieldSerializer(Field):
Represent a ChoiceField as (value, label).
"""
def __init__(self, choices, **kwargs):
self._choices = {k: v for k, v in choices}
self._choices = dict()
for k, v in choices:
# Unpack grouped choices
if type(v) in [list, tuple]:
for k2, v2 in v:
self._choices[k2] = v2
else:
self._choices[k] = v
super(ChoiceFieldSerializer, self).__init__(**kwargs)
def to_representation(self, obj):