CORD-879 eliminate proxy models in onos-service
Change-Id: I9d6bb02d003eb3ddd355210dcd82c3a19cf4f615
diff --git a/xos/admin.py b/xos/admin.py
index d33a3eb..5ab2f1c 100644
--- a/xos/admin.py
+++ b/xos/admin.py
@@ -18,35 +18,6 @@
from django.core.urlresolvers import reverse
from django.contrib.admin.utils import quote
-class ONOSServiceForm(forms.ModelForm):
- rest_hostname = forms.CharField(required=False)
- rest_port = forms.CharField(required=False)
- no_container = forms.BooleanField(required=False)
-# external_hostname = forms.CharField(required=False)
-# external_container = forms.CharField(required=False)
-
- def __init__(self,*args,**kwargs):
- super (ONOSServiceForm,self ).__init__(*args,**kwargs)
- if self.instance:
- # fields for the attributes
- self.fields['rest_hostname'].initial = self.instance.rest_hostname
- self.fields['rest_port'].initial = self.instance.rest_port
- self.fields['no_container'].initial = self.instance.no_container
-# self.fields['external_hostname'].initial = self.instance.external_hostname
-# self.fields['external_container'].initial = self.instance.external_hostname
-
- def save(self, commit=True):
- self.instance.rest_hostname = self.cleaned_data.get("rest_hostname")
- self.instance.rest_port = self.cleaned_data.get("rest_port")
- self.instance.no_container = self.cleaned_data.get("no_container")
-# self.instance.external_hostname = self.cleaned_data.get("external_hostname")
-# self.instance.external_container = self.cleaned_data.get("external_container")
- return super(ONOSServiceForm, self).save(commit=commit)
-
- class Meta:
- model = ONOSService
- fields = '__all__'
-
class ONOSServiceAdmin(ReadOnlyAwareAdmin):
model = ONOSService
verbose_name = "ONOS Service"
@@ -56,7 +27,6 @@
fieldsets = [(None, {'fields': ['backend_status_text', 'name','enabled','versionNumber', 'description',"view_url","icon_url", "rest_hostname", "rest_port", "no_container" ], 'classes':['suit-tab suit-tab-general']})]
readonly_fields = ('backend_status_text', )
inlines = [SliceInline,ServiceAttrAsTabInline,ServicePrivilegeInline]
- form = ONOSServiceForm
extracontext_registered_admins = True
@@ -76,30 +46,18 @@
return ONOSService.get_service_objects_by_user(request.user)
class ONOSAppForm(forms.ModelForm):
- creator = forms.ModelChoiceField(queryset=User.objects.all())
- name = forms.CharField()
- dependencies = forms.CharField(required=False)
-
def __init__(self,*args,**kwargs):
super (ONOSAppForm,self ).__init__(*args,**kwargs)
self.fields['kind'].widget.attrs['readonly'] = True
- self.fields['provider_service'].queryset = ONOSService.get_service_objects().all()
- if self.instance:
- # fields for the attributes
- self.fields['creator'].initial = self.instance.creator
- self.fields['name'].initial = self.instance.name
- self.fields['dependencies'].initial = self.instance.dependencies
+ self.fields['provider_service'].queryset = ONOSService.objects.all()
if (not self.instance) or (not self.instance.pk):
# default fields for an 'add' form
self.fields['kind'].initial = ONOS_KIND
self.fields['creator'].initial = get_request().user
- if ONOSService.get_service_objects().exists():
+ if ONOSService.objects.exists():
self.fields["provider_service"].initial = ONOSService.get_service_objects().all()[0]
def save(self, commit=True):
- self.instance.creator = self.cleaned_data.get("creator")
- self.instance.name = self.cleaned_data.get("name")
- self.instance.dependencies = self.cleaned_data.get("dependencies")
return super(ONOSAppForm, self).save(commit=commit)
class Meta: