CORD-1244 cleanup use of get_tenant/get_service
Change-Id: Iae02c3d73d64a105dadade3e64f73cad885c34fa
diff --git a/xos/admin.py b/xos/admin.py
index 829f7f1..d6745eb 100644
--- a/xos/admin.py
+++ b/xos/admin.py
@@ -57,7 +57,7 @@
)
def get_queryset(self, request):
- return ExampleService.get_service_objects_by_user(request.user)
+ return ExampleService.select_by_user(request.user)
admin.site.register(ExampleService, ExampleServiceAdmin)
@@ -75,7 +75,7 @@
self.fields['kind'].widget.attrs['readonly'] = True
self.fields['kind'].initial = SERVICE_NAME
- self.fields['provider_service'].queryset = ExampleService.get_service_objects().all()
+ self.fields['provider_service'].queryset = ExampleService.objects.all()
if self.instance:
self.fields['creator'].initial = self.instance.creator
@@ -83,8 +83,8 @@
if (not self.instance) or (not self.instance.pk):
self.fields['creator'].initial = get_request().user
- if ExampleService.get_service_objects().exists():
- self.fields['provider_service'].initial = ExampleService.get_service_objects().all()[0]
+ if ExampleService.objects.exists():
+ self.fields['provider_service'].initial = ExampleService.objects.all()[0]
def save(self, commit=True):
self.instance.creator = self.cleaned_data.get('creator')
@@ -112,7 +112,7 @@
suit_form_tabs = (('general', 'Details'),)
def get_queryset(self, request):
- return ExampleTenant.get_tenant_objects_by_user(request.user)
+ return ExampleTenant.select_by_user(request.user)
admin.site.register(ExampleTenant, ExampleTenantAdmin)
diff --git a/xos/api/service/exampleservice.py b/xos/api/service/exampleservice.py
index d8fe23a..467a4bd 100644
--- a/xos/api/service/exampleservice.py
+++ b/xos/api/service/exampleservice.py
@@ -36,7 +36,7 @@
base_name = "exampleservice"
method_name = "exampleservice"
method_kind = "viewset"
- queryset = ExampleService.get_service_objects().all()
+ queryset = ExampleService.objects.all()
serializer_class = ExampleServiceSerializer
@classmethod
diff --git a/xos/api/tenant/exampletenant.py b/xos/api/tenant/exampletenant.py
index f4778cc..386a77e 100644
--- a/xos/api/tenant/exampletenant.py
+++ b/xos/api/tenant/exampletenant.py
@@ -12,14 +12,14 @@
from services.exampleservice.models import ExampleTenant, ExampleService
def get_default_example_service():
- example_services = ExampleService.get_service_objects().all()
+ example_services = ExampleService.objects.all()
if example_services:
return example_services[0]
return None
class ExampleTenantSerializer(PlusModelSerializer):
id = ReadOnlyField()
- provider_service = serializers.PrimaryKeyRelatedField(queryset=ExampleService.get_service_objects().all(), default=get_default_example_service)
+ provider_service = serializers.PrimaryKeyRelatedField(queryset=ExampleService.objects.all(), default=get_default_example_service)
tenant_message = serializers.CharField(required=False)
backend_status = ReadOnlyField()
@@ -36,7 +36,7 @@
base_name = "exampletenant"
method_name = "exampletenant"
method_kind = "viewset"
- queryset = ExampleTenant.get_tenant_objects().all()
+ queryset = ExampleTenant.objects.all()
serializer_class = ExampleTenantSerializer
@classmethod
diff --git a/xos/attic/exampletenant_model.py b/xos/attic/exampletenant_model.py
index ad69d03..9eb1f86 100644
--- a/xos/attic/exampletenant_model.py
+++ b/xos/attic/exampletenant_model.py
@@ -1,5 +1,5 @@
def __init__(self, *args, **kwargs):
- exampleservice = ExampleService.get_service_objects().all()
+ exampleservice = ExampleService.objects.all()
if exampleservice:
self._meta.get_field('provider_service').default = exampleservice[0].id
super(ExampleTenant, self).__init__(*args, **kwargs)
diff --git a/xos/tosca/resources/exampletenant.py b/xos/tosca/resources/exampletenant.py
index d4e4683..2675189 100644
--- a/xos/tosca/resources/exampletenant.py
+++ b/xos/tosca/resources/exampletenant.py
@@ -20,7 +20,7 @@
def get_existing_objs(self):
args = self.get_xos_args(throw_exception=False)
- return ExampleTenant.get_tenant_objects().filter(provider_service=args["provider_service"], service_specific_id=args["service_specific_id"])
+ return ExampleTenant.objects.filter(provider_service=args["provider_service"], service_specific_id=args["service_specific_id"])
return []
def can_delete(self, obj):