add identity and related dicts to subscriber
diff --git a/xos/api/tenant/cord/subscriber.py b/xos/api/tenant/cord/subscriber.py
index 490e1af..cb37ec4 100644
--- a/xos/api/tenant/cord/subscriber.py
+++ b/xos/api/tenant/cord/subscriber.py
@@ -50,6 +50,34 @@
d.update(value)
self.features = d
+ @property
+ def identity(self):
+ return {"account_num": self.service_specific_id}
+
+ @identity.setter
+ def identity(self, value):
+ self.service_specific_id = value.get("account_num", "")
+
+ def update_identity(self, value):
+ d=self.identity
+ d.update(value)
+ self.identity = d
+
+ @property
+ def related(self):
+ related = {}
+ if self.volt:
+ related["volt_id"] = self.volt.id
+ related["s_tag"] = self.volt.s_tag
+ related["c_tag"] = self.volt.c_tag
+ if self.volt.vcpe:
+ related["vsg_id"] = self.volt.vcpe.id
+ if self.volt.vcpe.instance:
+ related["instance_id"] = self.volt.vcpe.instance.id
+ related["instance_name"] = self.volt.vcpe.instance.name
+ related["wan_container_ip"] = self.volt.vcpe.wan_container_ip
+ return related
+
def save(self, *args, **kwargs):
super(CordSubscriberNew, self).save(*args, **kwargs)
@@ -60,18 +88,23 @@
uverse = serializers.BooleanField(required=False)
status = serializers.CharField(required=False)
+class IdentitySerializer(serializers.Serializer):
+ account_num = serializers.CharField(required=False)
+
class CordSubscriberSerializer(serializers.ModelSerializer, PlusSerializerMixin):
id = ReadOnlyField()
- service_specific_id = ReadOnlyField()
humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
- features = FeatureSerializer() # serializers.DictField()
+ features = FeatureSerializer()
+ identity = IdentitySerializer()
+ related = serializers.DictField(required=False)
class Meta:
model = CordSubscriberNew
fields = ('humanReadableName',
'id',
- 'service_specific_id',
- 'features')
+ 'features',
+ 'identity',
+ 'related')
def getHumanReadableName(self, obj):
return obj.__unicode__()
@@ -117,7 +150,7 @@
ser = FeatureSerializer(subscriber.features, data=request.data)
ser.is_valid(raise_exception = True)
subscriber.update_features(ser.validated_data)
- return Response(subscriber.features[feature])
+ return Response({feature: FeatureSerializer(subscriber.features).data[feature]})
def set_features(self, request, pk=None):
subscriber = self.get_object()