set_subscriber_device_feature working
diff --git a/xos/api/examples/cord/set_subscriber_device_feature.sh b/xos/api/examples/cord/set_subscriber_device_feature.sh
new file mode 100755
index 0000000..73d84b0
--- /dev/null
+++ b/xos/api/examples/cord/set_subscriber_device_feature.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+source ./config.sh
+source ./util.sh
+
+ACCOUNT_NUM=1238
+MAC="19:28:37:46:55"
+
+SUBSCRIBER_ID=$(lookup_account_num $ACCOUNT_NUM)
+if [[ $? != 0 ]]; then
+ exit -1
+fi
+
+DATA=$(cat <<EOF
+{"uplink_speed": 111111}
+EOF
+)
+
+curl -H "Accept: application/json; indent=4" -H "Content-Type: application/json" -u $AUTH -X PUT -d "$DATA" $HOST/api/tenant/cord/subscriber/$SUBSCRIBER_ID/devices/$MAC/features/uplink_speed/
diff --git a/xos/api/tenant/cord/subscriber.py b/xos/api/tenant/cord/subscriber.py
index 6984671..f0868a5 100644
--- a/xos/api/tenant/cord/subscriber.py
+++ b/xos/api/tenant/cord/subscriber.py
@@ -118,11 +118,16 @@
self.d["uplink_speed"] = value.get("uplink_speed", None)
self.d["downlink_speed"] = value.get("downlink_speed", None)
+ def update_features(self, value):
+ d=self.features
+ d.update(value)
+ self.features = d
+
def save(self):
if self.subscriber:
dev=self.subscriber.find_device(self.mac)
if dev:
- self.subscriber.update_device(mac, **self.d)
+ self.subscriber.update_device(**self.d)
else:
self.subscriber.create_device(**self.d)
@@ -313,6 +318,7 @@
device.update_features(ser.validated_data)
device.save()
subscriber.save()
+ return Response({feature: DeviceFeatureSerializer(device.features).data[feature]})
def account_num_detail(self, pk=None, account_num=None):
object_list = CordSubscriberNew.get_tenant_objects().all()