CORD-1337 use content_type strings instead of ids
Change-Id: Ie23e2aae0a3165e7d43c2804704b3e9e6f64819c
diff --git a/xos/admin.py b/xos/admin.py
index 62c7c56..1ecf83f 100644
--- a/xos/admin.py
+++ b/xos/admin.py
@@ -56,7 +56,7 @@
self.fields['provider_service'].queryset = VTRService.get_service_objects().all()
if self.instance:
if self.instance.target_id:
- self.fields["target"].initial = CordSubscriberRoot.objects.get(id=self.instance.target_id)
+ self.fields["target"].initial = CordSubscriberRoot.get_content_object(self.instance.target_type, self.instance.target_id)
if (not self.instance) or (not self.instance.pk):
self.fields['kind'].initial = VTR_KIND
if VTRService.get_service_objects().exists():
@@ -64,7 +64,7 @@
def save(self, commit=True):
if self.cleaned_data.get("target"):
- self.instance.target_type = ContentType.objects.get_for_model(CordSubscriberRoot)
+ self.instance.target_type = self.cleaned_data.get("target").get_content_type_key()
self.instance.target_id = self.cleaned_data.get("target").id
return super(VTRTenantForm, self).save(commit=commit)
diff --git a/xos/vtr.xproto b/xos/vtr.xproto
index 080c3e7..e60425f 100644
--- a/xos/vtr.xproto
+++ b/xos/vtr.xproto
@@ -8,7 +8,7 @@
optional string argument = 3 [db_index = False, max_length = 40, null = True, content_type = "stripped", blank = True];
optional string result = 4 [db_index = False, null = True, blank = True];
optional string result_code = 5 [db_index = False, max_length = 32, null = True, content_type = "stripped", blank = True];
- required manytoone target_type->ContentType:vtrtenant = 6 [db_index = True, null = False, blank = False];
+ required string target_type = 6 [max_length = 1024, content_type = "stripped", blank = False, help_text = "Target type id linked to this vtrtenant", null = False, db_index = False];
required uint32 target_id = 7 [db_index = False, null = False, blank = False];
}