CORD-1244 cleanup use of get_tenant/get_service
Change-Id: I96cfe6148d7dd045e892f9130f741041dbfc7295
diff --git a/xos/admin.py b/xos/admin.py
index fe2c10c..78e00fd 100644
--- a/xos/admin.py
+++ b/xos/admin.py
@@ -55,7 +55,7 @@
def __init__(self,*args,**kwargs):
super (VOLTTenantForm,self ).__init__(*args,**kwargs)
self.fields['kind'].widget.attrs['readonly'] = True
- self.fields['provider_service'].queryset = VOLTService.get_service_objects().all()
+ self.fields['provider_service'].queryset = VOLTService.objects.all()
if self.instance:
# fields for the attributes
self.fields['c_tag'].initial = self.instance.c_tag
@@ -65,8 +65,8 @@
# default fields for an 'add' form
self.fields['kind'].initial = VOLT_KIND
self.fields['creator'].initial = get_request().user
- if VOLTService.get_service_objects().exists():
- self.fields["provider_service"].initial = VOLTService.get_service_objects().all()[0]
+ if VOLTService.objects.exists():
+ self.fields["provider_service"].initial = VOLTService.objects.all()[0]
def save(self, commit=True):
self.instance.s_tag = self.cleaned_data.get("s_tag")
@@ -91,7 +91,7 @@
suit_form_tabs = (('general','Details'),)
def get_queryset(self, request):
- return VOLTTenant.get_tenant_objects_by_user(request.user)
+ return VOLTTenant.select_by_user(request.user)
class AccessDeviceInline(XOSTabularInline):
model = AccessDevice
diff --git a/xos/api/tenant/cord/subscriber.py b/xos/api/tenant/cord/subscriber.py
index c26fb20..036e4cc 100644
--- a/xos/api/tenant/cord/subscriber.py
+++ b/xos/api/tenant/cord/subscriber.py
@@ -359,7 +359,7 @@
return Response({identity: DeviceIdentitySerializer(device.identity).data[identity]})
def account_num_detail(self, pk=None, account_num=None):
- object_list = CordSubscriberNew.get_tenant_objects().all()
+ object_list = CordSubscriberNew.objects.all()
object_list = [x for x in object_list if x.service_specific_id == account_num]
if not object_list:
return Response("Failed to find account_num %s" % account_num, status=status.HTTP_404_NOT_FOUND)
@@ -367,14 +367,14 @@
return Response( object_list[0].id )
def ssidlist(self, request):
- object_list = CordSubscriberNew.get_tenant_objects().all()
+ object_list = CordSubscriberNew.objects.all()
ssidmap = [ {"service_specific_id": x.service_specific_id, "subscriber_id": x.id} for x in object_list ]
return Response({"ssidmap": ssidmap})
def ssiddetail(self, pk=None, ssid=None):
- object_list = CordSubscriberNew.get_tenant_objects().all()
+ object_list = CordSubscriberNew.objects.all()
ssidmap = [ {"service_specific_id": x.service_specific_id, "subscriber_id": x.id} for x in object_list if str(x.service_specific_id)==str(ssid) ]
diff --git a/xos/api/tenant/cord/volt.py b/xos/api/tenant/cord/volt.py
index 50bd5a6..7da8e4f 100644
--- a/xos/api/tenant/cord/volt.py
+++ b/xos/api/tenant/cord/volt.py
@@ -12,7 +12,7 @@
from api.xosapi_helpers import PlusModelSerializer, XOSViewSet, ReadOnlyField
def get_default_volt_service():
- volt_services = VOLTService.get_service_objects().all()
+ volt_services = VOLTService.objects.all()
if volt_services:
return volt_services[0].id
return None
@@ -28,7 +28,7 @@
@subscriber.setter
def subscriber(self, value):
- self.subscriber_root = value # CordSubscriberRoot.get_tenant_objects().get(id=value)
+ self.subscriber_root = value
@property
def related(self):
@@ -48,7 +48,7 @@
service_specific_id = serializers.CharField(required=False)
s_tag = serializers.CharField()
c_tag = serializers.CharField()
- subscriber = serializers.PrimaryKeyRelatedField(queryset=CordSubscriberRoot.get_tenant_objects().all(), required=False)
+ subscriber = serializers.PrimaryKeyRelatedField(queryset=CordSubscriberRoot.objects.all(), required=False)
related = serializers.DictField(required=False)
property_fields=["subscriber"]
@@ -65,7 +65,7 @@
base_name = "volt"
method_name = "volt"
method_kind = "viewset"
- queryset = VOLTTenantForAPI.get_tenant_objects().all() # select_related().all()
+ queryset = VOLTTenantForAPI.objects.all()
serializer_class = VOLTTenantSerializer
@classmethod
diff --git a/xos/attic/volttenant_model.py b/xos/attic/volttenant_model.py
index e9a101b..0e87f70 100644
--- a/xos/attic/volttenant_model.py
+++ b/xos/attic/volttenant_model.py
@@ -1,5 +1,5 @@
def __init__(self, *args, **kwargs):
- volt_services = VOLTService.get_service_objects().all()
+ volt_services = VOLTService.objects.all()
if volt_services:
self._meta.get_field("provider_service").default = volt_services[0].id
super(VOLTTenant, self).__init__(*args, **kwargs)
@@ -48,7 +48,7 @@
if self.vcpe is None:
from services.vsg.models import VSGService, VSGTenant
- vsgServices = VSGService.get_service_objects().all()
+ vsgServices = VSGService.objects.all()
if not vsgServices:
raise XOSConfigurationError("No VSG Services available")
@@ -66,7 +66,7 @@
# TODO: This probably goes away when we rethink the ONOS-to-XOS
# vOLT API.
- subs = CordSubscriberRoot.get_tenant_objects().filter(service_specific_id = self.service_specific_id)
+ subs = CordSubscriberRoot.objects.filter(service_specific_id = self.service_specific_id)
if subs:
sub = subs[0]
else: