blob: 40e0f29f042ddd394c7bc2644b3eff5fad3bcf29 [file] [log] [blame]
Scott Baker2986b1e2015-04-21 16:59:04 -07001from django.contrib import admin
2
Scott Bakere01ee762015-12-31 10:18:28 -08003from services.cord.models import *
Scott Baker2986b1e2015-04-21 16:59:04 -07004from django import forms
5from django.utils.safestring import mark_safe
6from django.contrib.auth.admin import UserAdmin
7from django.contrib.admin.widgets import FilteredSelectMultiple
8from django.contrib.auth.forms import ReadOnlyPasswordHashField
9from django.contrib.auth.signals import user_logged_in
10from django.utils import timezone
11from django.contrib.contenttypes import generic
12from suit.widgets import LinkedSelect
Scott Baker527326e2015-07-23 12:06:26 -070013from core.admin import ServiceAppAdmin,SliceInline,ServiceAttrAsTabInline, ReadOnlyAwareAdmin, XOSTabularInline, ServicePrivilegeInline, TenantRootTenantInline, TenantRootPrivilegeInline
Scott Bakerb2f5efe2015-09-10 16:01:58 -070014from core.middleware import get_request
Scott Baker2986b1e2015-04-21 16:59:04 -070015
16from functools import update_wrapper
17from django.contrib.admin.views.main import ChangeList
18from django.core.urlresolvers import reverse
19from django.contrib.admin.utils import quote
20
Scott Baker932a16c2015-04-21 17:15:18 -070021#-----------------------------------------------------------------------------
22# vOLT
23#-----------------------------------------------------------------------------
Scott Baker2986b1e2015-04-21 16:59:04 -070024
25class VOLTServiceAdmin(ReadOnlyAwareAdmin):
26 model = VOLTService
27 verbose_name = "vOLT Service"
28 verbose_name_plural = "vOLT Service"
29 list_display = ("backend_status_icon", "name", "enabled")
30 list_display_links = ('backend_status_icon', 'name', )
Scott Baker932a16c2015-04-21 17:15:18 -070031 fieldsets = [(None, {'fields': ['backend_status_text', 'name','enabled','versionNumber', 'description',"view_url","icon_url" ], 'classes':['suit-tab suit-tab-general']})]
Scott Baker2986b1e2015-04-21 16:59:04 -070032 readonly_fields = ('backend_status_text', )
Scott Baker559be722015-05-15 09:08:19 -070033 inlines = [SliceInline,ServiceAttrAsTabInline,ServicePrivilegeInline]
Scott Baker2986b1e2015-04-21 16:59:04 -070034
35 extracontext_registered_admins = True
36
37 user_readonly_fields = ["name", "enabled", "versionNumber", "description"]
38
39 suit_form_tabs =(('general', 'vOLT Service Details'),
40 ('administration', 'Administration'),
41 #('tools', 'Tools'),
42 ('slices','Slices'),
43 ('serviceattrs','Additional Attributes'),
Scott Baker559be722015-05-15 09:08:19 -070044 ('serviceprivileges','Privileges'),
Scott Baker2986b1e2015-04-21 16:59:04 -070045 )
46
47 suit_form_includes = (('voltadmin.html', 'top', 'administration'),
48 ) #('hpctools.html', 'top', 'tools') )
49
50 def queryset(self, request):
Scott Baker16573d32015-07-24 15:36:02 -070051 return VOLTService.get_service_objects_by_user(request.user)
Scott Baker2986b1e2015-04-21 16:59:04 -070052
53class VOLTTenantForm(forms.ModelForm):
Scott Baker89a338c2015-11-09 20:25:21 -080054 s_tag = forms.CharField()
55 c_tag = forms.CharField()
Scott Baker800f9c12015-07-13 13:08:07 -070056 creator = forms.ModelChoiceField(queryset=User.objects.all())
57
Sapan Bhatia67ea0d72016-01-14 11:41:38 -050058 def __init__(self,*args,**kwargs):
59 super (VOLTTenantForm,self ).__init__(*args,**kwargs)
60 self.fields['kind'].widget.attrs['readonly'] = True
61 self.fields['provider_service'].queryset = VOLTService.get_service_objects().all()
62 if self.instance:
63 # fields for the attributes
64 self.fields['c_tag'].initial = self.instance.c_tag
65 self.fields['s_tag'].initial = self.instance.s_tag
66 self.fields['creator'].initial = self.instance.creator
67 if (not self.instance) or (not self.instance.pk):
68 # default fields for an 'add' form
69 self.fields['kind'].initial = VOLT_KIND
70 self.fields['creator'].initial = get_request().user
71 if VOLTService.get_service_objects().exists():
72 self.fields["provider_service"].initial = VOLTService.get_service_objects().all()[0]
73
74 def save(self, commit=True):
75 self.instance.s_tag = self.cleaned_data.get("s_tag")
76 self.instance.c_tag = self.cleaned_data.get("c_tag")
77 self.instance.creator = self.cleaned_data.get("creator")
78 return super(VOLTTenantForm, self).save(commit=commit)
79
80 class Meta:
Scott Baker2986b1e2015-04-21 16:59:04 -070081 model = VOLTTenant
82
83class VOLTTenantAdmin(ReadOnlyAwareAdmin):
Scott Baker89a338c2015-11-09 20:25:21 -080084 list_display = ('backend_status_icon', 'id', 'service_specific_id', 's_tag', 'c_tag', 'subscriber_root' )
Scott Baker932a16c2015-04-21 17:15:18 -070085 list_display_links = ('backend_status_icon', 'id')
Scott Bakerbb482ae2015-07-21 18:18:25 -070086 fieldsets = [ (None, {'fields': ['backend_status_text', 'kind', 'provider_service', 'subscriber_root', 'service_specific_id', # 'service_specific_attribute',
Scott Baker89a338c2015-11-09 20:25:21 -080087 's_tag', 'c_tag', 'creator'],
Scott Bakerbb482ae2015-07-21 18:18:25 -070088 'classes':['suit-tab suit-tab-general']})]
Scott Baker800f9c12015-07-13 13:08:07 -070089 readonly_fields = ('backend_status_text', 'service_specific_attribute')
Scott Baker2986b1e2015-04-21 16:59:04 -070090 form = VOLTTenantForm
91
92 suit_form_tabs = (('general','Details'),)
93
94 def queryset(self, request):
Scott Baker16573d32015-07-24 15:36:02 -070095 return VOLTTenant.get_tenant_objects_by_user(request.user)
Scott Baker2986b1e2015-04-21 16:59:04 -070096
Scott Baker932a16c2015-04-21 17:15:18 -070097#-----------------------------------------------------------------------------
98# vCPE
99#-----------------------------------------------------------------------------
100
Scott Baker4698b922016-02-11 12:07:10 -0800101class VSGServiceForm(forms.ModelForm):
Scott Bakera0886fb2015-07-15 18:08:06 -0700102 bbs_api_hostname = forms.CharField(required=False)
103 bbs_api_port = forms.IntegerField(required=False)
Scott Baker3d2493b2015-07-15 17:42:43 -0700104 bbs_server = forms.CharField(required=False)
105 backend_network_label = forms.CharField(required=False)
106 bbs_slice = forms.ModelChoiceField(queryset=Slice.objects.all(), required=False)
Scott Baker4d3cc752016-02-18 06:43:02 -0800107 wan_container_gateway_ip = forms.CharField(required=False)
108 wan_container_gateway_mac = forms.CharField(required=False)
109 wan_container_netbits = forms.CharField(required=False)
Scott Baker7ba272e2015-07-13 14:30:25 -0700110
Sapan Bhatia67ea0d72016-01-14 11:41:38 -0500111 def __init__(self,*args,**kwargs):
Scott Baker4698b922016-02-11 12:07:10 -0800112 super (VSGServiceForm,self ).__init__(*args,**kwargs)
Sapan Bhatia67ea0d72016-01-14 11:41:38 -0500113 if self.instance:
114 self.fields['bbs_api_hostname'].initial = self.instance.bbs_api_hostname
115 self.fields['bbs_api_port'].initial = self.instance.bbs_api_port
116 self.fields['bbs_server'].initial = self.instance.bbs_server
117 self.fields['backend_network_label'].initial = self.instance.backend_network_label
118 self.fields['bbs_slice'].initial = self.instance.bbs_slice
Scott Baker4d3cc752016-02-18 06:43:02 -0800119 self.fields['wan_container_gateway_ip'].initial = self.instance.wan_container_gateway_ip
120 self.fields['wan_container_gateway_mac'].initial = self.instance.wan_container_gateway_mac
121 self.fields['wan_container_netbits'].initial = self.instance.wan_container_netbits
Sapan Bhatia67ea0d72016-01-14 11:41:38 -0500122
123 def save(self, commit=True):
124 self.instance.bbs_api_hostname = self.cleaned_data.get("bbs_api_hostname")
125 self.instance.bbs_api_port = self.cleaned_data.get("bbs_api_port")
126 self.instance.bbs_server = self.cleaned_data.get("bbs_server")
127 self.instance.backend_network_label = self.cleaned_data.get("backend_network_label")
128 self.instance.bbs_slice = self.cleaned_data.get("bbs_slice")
Scott Baker4d3cc752016-02-18 06:43:02 -0800129 self.instance.wan_container_gateway_ip = self.cleaned_data.get("wan_container_gateway_ip")
130 self.instance.wan_container_gateway_mac = self.cleaned_data.get("wan_container_gateway_mac")
131 self.instance.wan_container_netbits = self.cleaned_data.get("wan_container_netbits")
Scott Baker4698b922016-02-11 12:07:10 -0800132 return super(VSGServiceForm, self).save(commit=commit)
Sapan Bhatia67ea0d72016-01-14 11:41:38 -0500133
134 class Meta:
Scott Baker4698b922016-02-11 12:07:10 -0800135 model = VSGService
Scott Baker7ba272e2015-07-13 14:30:25 -0700136
Scott Baker4698b922016-02-11 12:07:10 -0800137class VSGServiceAdmin(ReadOnlyAwareAdmin):
138 model = VSGService
Scott Baker932a16c2015-04-21 17:15:18 -0700139 verbose_name = "vCPE Service"
140 verbose_name_plural = "vCPE Service"
141 list_display = ("backend_status_icon", "name", "enabled")
142 list_display_links = ('backend_status_icon', 'name', )
Scott Baker3d2493b2015-07-15 17:42:43 -0700143 fieldsets = [(None, {'fields': ['backend_status_text', 'name','enabled','versionNumber', 'description', "view_url", "icon_url", "service_specific_attribute",],
144 'classes':['suit-tab suit-tab-general']}),
Scott Baker4d3cc752016-02-18 06:43:02 -0800145 ("backend config", {'fields': [ "backend_network_label", "bbs_api_hostname", "bbs_api_port", "bbs_server", "bbs_slice", "wan_container_gateway_ip", "wan_container_gateway_mac", "wan_container_netbits"],
Scott Baker3d2493b2015-07-15 17:42:43 -0700146 'classes':['suit-tab suit-tab-backend']}) ]
Scott Baker7ba272e2015-07-13 14:30:25 -0700147 readonly_fields = ('backend_status_text', "service_specific_attribute")
Scott Baker559be722015-05-15 09:08:19 -0700148 inlines = [SliceInline,ServiceAttrAsTabInline,ServicePrivilegeInline]
Scott Baker4698b922016-02-11 12:07:10 -0800149 form = VSGServiceForm
Scott Baker932a16c2015-04-21 17:15:18 -0700150
151 extracontext_registered_admins = True
152
153 user_readonly_fields = ["name", "enabled", "versionNumber", "description"]
154
Scott Baker3d2493b2015-07-15 17:42:43 -0700155 suit_form_tabs =(('general', 'Service Details'),
156 ('backend', 'Backend Config'),
Scott Baker932a16c2015-04-21 17:15:18 -0700157 ('administration', 'Administration'),
158 #('tools', 'Tools'),
159 ('slices','Slices'),
160 ('serviceattrs','Additional Attributes'),
Scott Baker559be722015-05-15 09:08:19 -0700161 ('serviceprivileges','Privileges') ,
Scott Baker932a16c2015-04-21 17:15:18 -0700162 )
163
164 suit_form_includes = (('vcpeadmin.html', 'top', 'administration'),
165 ) #('hpctools.html', 'top', 'tools') )
166
167 def queryset(self, request):
Scott Baker4698b922016-02-11 12:07:10 -0800168 return VSGService.get_service_objects_by_user(request.user)
Scott Baker932a16c2015-04-21 17:15:18 -0700169
Scott Baker664bbe52016-02-11 11:08:42 -0800170class VSGTenantForm(forms.ModelForm):
Scott Bakerbb482ae2015-07-21 18:18:25 -0700171 bbs_account = forms.CharField(required=False)
172 creator = forms.ModelChoiceField(queryset=User.objects.all())
Tony Mack3de59e32015-08-19 11:58:18 -0400173 instance = forms.ModelChoiceField(queryset=Instance.objects.all(),required=False)
Scott Bakerbb482ae2015-07-21 18:18:25 -0700174 last_ansible_hash = forms.CharField(required=False)
Scott Baker27fab492016-02-13 14:38:43 -0800175 wan_container_ip = forms.CharField(required=False)
Scott Baker4d3cc752016-02-18 06:43:02 -0800176 wan_container_mac = forms.CharField(required=False)
Scott Bakerbb482ae2015-07-21 18:18:25 -0700177
Sapan Bhatia67ea0d72016-01-14 11:41:38 -0500178 def __init__(self,*args,**kwargs):
Scott Baker664bbe52016-02-11 11:08:42 -0800179 super (VSGTenantForm,self ).__init__(*args,**kwargs)
Sapan Bhatia67ea0d72016-01-14 11:41:38 -0500180 self.fields['kind'].widget.attrs['readonly'] = True
Scott Baker4698b922016-02-11 12:07:10 -0800181 self.fields['provider_service'].queryset = VSGService.get_service_objects().all()
Sapan Bhatia67ea0d72016-01-14 11:41:38 -0500182 if self.instance:
183 # fields for the attributes
184 self.fields['bbs_account'].initial = self.instance.bbs_account
185 self.fields['creator'].initial = self.instance.creator
186 self.fields['instance'].initial = self.instance.instance
187 self.fields['last_ansible_hash'].initial = self.instance.last_ansible_hash
Scott Baker27fab492016-02-13 14:38:43 -0800188 self.fields['wan_container_ip'].initial = self.instance.wan_container_ip
Scott Baker4d3cc752016-02-18 06:43:02 -0800189 self.fields['wan_container_mac'].initial = self.instance.wan_container_mac
Sapan Bhatia67ea0d72016-01-14 11:41:38 -0500190 if (not self.instance) or (not self.instance.pk):
191 # default fields for an 'add' form
192 self.fields['kind'].initial = VCPE_KIND
193 self.fields['creator'].initial = get_request().user
Scott Baker4698b922016-02-11 12:07:10 -0800194 if VSGService.get_service_objects().exists():
195 self.fields["provider_service"].initial = VSGService.get_service_objects().all()[0]
Sapan Bhatia67ea0d72016-01-14 11:41:38 -0500196
197 def save(self, commit=True):
198 self.instance.creator = self.cleaned_data.get("creator")
199 self.instance.instance = self.cleaned_data.get("instance")
200 self.instance.last_ansible_hash = self.cleaned_data.get("last_ansible_hash")
Scott Baker664bbe52016-02-11 11:08:42 -0800201 return super(VSGTenantForm, self).save(commit=commit)
Sapan Bhatia67ea0d72016-01-14 11:41:38 -0500202
203 class Meta:
Scott Baker664bbe52016-02-11 11:08:42 -0800204 model = VSGTenant
Scott Baker932a16c2015-04-21 17:15:18 -0700205
Scott Baker664bbe52016-02-11 11:08:42 -0800206class VSGTenantAdmin(ReadOnlyAwareAdmin):
Scott Baker1b06b6c2015-07-06 14:40:20 -0700207 list_display = ('backend_status_icon', 'id', 'subscriber_tenant' )
Scott Baker932a16c2015-04-21 17:15:18 -0700208 list_display_links = ('backend_status_icon', 'id')
Scott Bakerbb482ae2015-07-21 18:18:25 -0700209 fieldsets = [ (None, {'fields': ['backend_status_text', 'kind', 'provider_service', 'subscriber_tenant', 'service_specific_id', # 'service_specific_attribute',
Scott Baker4d3cc752016-02-18 06:43:02 -0800210 'wan_container_ip', 'wan_container_mac', 'bbs_account', 'creator', 'instance', 'last_ansible_hash'],
Scott Bakerbb482ae2015-07-21 18:18:25 -0700211 'classes':['suit-tab suit-tab-general']})]
Scott Baker4d3cc752016-02-18 06:43:02 -0800212 readonly_fields = ('backend_status_text', 'service_specific_attribute', 'bbs_account', 'wan_container_ip', 'wan_container_mac')
Scott Baker664bbe52016-02-11 11:08:42 -0800213 form = VSGTenantForm
Scott Baker932a16c2015-04-21 17:15:18 -0700214
215 suit_form_tabs = (('general','Details'),)
216
217 def queryset(self, request):
Scott Baker664bbe52016-02-11 11:08:42 -0800218 return VSGTenant.get_tenant_objects_by_user(request.user)
Scott Baker932a16c2015-04-21 17:15:18 -0700219
220#-----------------------------------------------------------------------------
221# vBNG
222#-----------------------------------------------------------------------------
223
Scott Baker3d7ec1a2015-07-21 18:24:21 -0700224class VBNGServiceForm(forms.ModelForm):
225 vbng_url = forms.CharField(required=False)
226
Sapan Bhatia67ea0d72016-01-14 11:41:38 -0500227 def __init__(self,*args,**kwargs):
228 super (VBNGServiceForm,self ).__init__(*args,**kwargs)
229 if self.instance:
230 self.fields['vbng_url'].initial = self.instance.vbng_url
231
232 def save(self, commit=True):
233 self.instance.vbng_url = self.cleaned_data.get("vbng_url")
234 return super(VBNGServiceForm, self).save(commit=commit)
235
236 class Meta:
Scott Baker3d7ec1a2015-07-21 18:24:21 -0700237 model = VBNGService
238
Scott Baker932a16c2015-04-21 17:15:18 -0700239class VBNGServiceAdmin(ReadOnlyAwareAdmin):
240 model = VBNGService
241 verbose_name = "vBNG Service"
242 verbose_name_plural = "vBNG Service"
243 list_display = ("backend_status_icon", "name", "enabled")
244 list_display_links = ('backend_status_icon', 'name', )
Scott Baker3d7ec1a2015-07-21 18:24:21 -0700245 fieldsets = [(None, {'fields': ['backend_status_text', 'name','enabled','versionNumber', 'description', "view_url", "icon_url",
246 'vbng_url' ],
247 'classes':['suit-tab suit-tab-general']})]
Scott Baker932a16c2015-04-21 17:15:18 -0700248 readonly_fields = ('backend_status_text', )
Scott Baker559be722015-05-15 09:08:19 -0700249 inlines = [SliceInline,ServiceAttrAsTabInline,ServicePrivilegeInline]
Scott Baker3d7ec1a2015-07-21 18:24:21 -0700250 form = VBNGServiceForm
Scott Baker932a16c2015-04-21 17:15:18 -0700251
252 extracontext_registered_admins = True
253
254 user_readonly_fields = ["name", "enabled", "versionNumber", "description"]
255
256 suit_form_tabs =(('general', 'vBNG Service Details'),
257 ('administration', 'Administration'),
258 #('tools', 'Tools'),
259 ('slices','Slices'),
260 ('serviceattrs','Additional Attributes'),
Scott Baker559be722015-05-15 09:08:19 -0700261 ('serviceprivileges','Privileges'),
Scott Baker932a16c2015-04-21 17:15:18 -0700262 )
263
264 suit_form_includes = (('vbngadmin.html', 'top', 'administration'),
265 ) #('hpctools.html', 'top', 'tools') )
266
267 def queryset(self, request):
Scott Baker16573d32015-07-24 15:36:02 -0700268 return VBNGService.get_service_objects_by_user(request.user)
Scott Baker932a16c2015-04-21 17:15:18 -0700269
270class VBNGTenantForm(forms.ModelForm):
Scott Bakerbb482ae2015-07-21 18:18:25 -0700271 routeable_subnet = forms.CharField(required=False)
272 mapped_hostname = forms.CharField(required=False)
273 mapped_ip = forms.CharField(required=False)
274 mapped_mac = forms.CharField(required=False)
275
Sapan Bhatia67ea0d72016-01-14 11:41:38 -0500276 def __init__(self,*args,**kwargs):
277 super (VBNGTenantForm,self ).__init__(*args,**kwargs)
278 self.fields['kind'].widget.attrs['readonly'] = True
279 self.fields['provider_service'].queryset = VBNGService.get_service_objects().all()
280 if self.instance:
281 # fields for the attributes
282 self.fields['routeable_subnet'].initial = self.instance.routeable_subnet
283 self.fields['mapped_hostname'].initial = self.instance.mapped_hostname
284 self.fields['mapped_ip'].initial = self.instance.mapped_ip
285 self.fields['mapped_mac'].initial = self.instance.mapped_mac
286 if (not self.instance) or (not self.instance.pk):
287 # default fields for an 'add' form
288 self.fields['kind'].initial = VBNG_KIND
289 if VBNGService.get_service_objects().exists():
290 self.fields["provider_service"].initial = VBNGService.get_service_objects().all()[0]
291
292 def save(self, commit=True):
293 self.instance.routeable_subnet = self.cleaned_data.get("routeable_subnet")
294 self.instance.mapped_hostname = self.cleaned_data.get("mapped_hostname")
295 self.instance.mapped_ip = self.cleaned_data.get("mapped_ip")
296 self.instance.mapped_mac = self.cleaned_data.get("mapped_mac")
297 return super(VBNGTenantForm, self).save(commit=commit)
298
299 class Meta:
Scott Baker932a16c2015-04-21 17:15:18 -0700300 model = VBNGTenant
301
302class VBNGTenantAdmin(ReadOnlyAwareAdmin):
Scott Baker1b06b6c2015-07-06 14:40:20 -0700303 list_display = ('backend_status_icon', 'id', 'subscriber_tenant' )
Scott Baker932a16c2015-04-21 17:15:18 -0700304 list_display_links = ('backend_status_icon', 'id')
Scott Bakerbb482ae2015-07-21 18:18:25 -0700305 fieldsets = [ (None, {'fields': ['backend_status_text', 'kind', 'provider_service', 'subscriber_tenant', 'service_specific_id', # 'service_specific_attribute',
306 'routeable_subnet', 'mapped_hostname', 'mapped_ip', 'mapped_mac'],
307 'classes':['suit-tab suit-tab-general']})]
308 readonly_fields = ('backend_status_text', 'service_specific_attribute')
Scott Baker932a16c2015-04-21 17:15:18 -0700309 form = VBNGTenantForm
310
311 suit_form_tabs = (('general','Details'),)
312
313 def queryset(self, request):
Scott Baker16573d32015-07-24 15:36:02 -0700314 return VBNGTenant.get_tenant_objects_by_user(request.user)
Scott Baker932a16c2015-04-21 17:15:18 -0700315
Scott Baker527326e2015-07-23 12:06:26 -0700316#-----------------------------------------------------------------------------
317# CordSubscriberRoot
318#-----------------------------------------------------------------------------
319
Scott Bakerab123102015-07-24 10:15:01 -0700320class VOLTTenantInline(XOSTabularInline):
321 model = VOLTTenant
322 fields = ['provider_service', 'subscriber_root', 'service_specific_id']
323 readonly_fields = ['provider_service', 'subscriber_root', 'service_specific_id']
324 extra = 0
325 max_num = 0
326 suit_classes = 'suit-tab suit-tab-volttenants'
327 fk_name = 'subscriber_root'
328 verbose_name = 'subscribed tenant'
329 verbose_name_plural = 'subscribed tenants'
330
331 @property
332 def selflink_reverse_path(self):
333 return "admin:cord_volttenant_change"
334
335 def queryset(self, request):
336 qs = super(VOLTTenantInline, self).queryset(request)
337 return qs.filter(kind=VOLT_KIND)
338
Scott Baker527326e2015-07-23 12:06:26 -0700339class CordSubscriberRootForm(forms.ModelForm):
340 url_filter_level = forms.CharField(required = False)
341
Sapan Bhatia67ea0d72016-01-14 11:41:38 -0500342 def __init__(self,*args,**kwargs):
343 super (CordSubscriberRootForm,self ).__init__(*args,**kwargs)
344 self.fields['kind'].widget.attrs['readonly'] = True
345 if self.instance:
346 self.fields['url_filter_level'].initial = self.instance.url_filter_level
347 if (not self.instance) or (not self.instance.pk):
348 # default fields for an 'add' form
349 self.fields['kind'].initial = CORD_SUBSCRIBER_KIND
350
351 def save(self, commit=True):
352 self.instance.url_filter_level = self.cleaned_data.get("url_filter_level")
353 return super(CordSubscriberRootForm, self).save(commit=commit)
354
355 class Meta:
Scott Baker527326e2015-07-23 12:06:26 -0700356 model = CordSubscriberRoot
357
358class CordSubscriberRootAdmin(ReadOnlyAwareAdmin):
359 list_display = ('backend_status_icon', 'id', 'name', )
360 list_display_links = ('backend_status_icon', 'id', 'name', )
361 fieldsets = [ (None, {'fields': ['backend_status_text', 'kind', 'name', 'service_specific_id', # 'service_specific_attribute',
362 'url_filter_level'],
363 'classes':['suit-tab suit-tab-general']})]
364 readonly_fields = ('backend_status_text', 'service_specific_attribute', 'bbs_account')
365 form = CordSubscriberRootForm
Scott Bakerab123102015-07-24 10:15:01 -0700366 inlines = (VOLTTenantInline, TenantRootPrivilegeInline)
Scott Baker527326e2015-07-23 12:06:26 -0700367
368 suit_form_tabs =(('general', 'Cord Subscriber Root Details'),
Scott Bakerab123102015-07-24 10:15:01 -0700369 ('volttenants','VOLT Tenancy'),
Scott Baker527326e2015-07-23 12:06:26 -0700370 ('tenantrootprivileges','Privileges')
371 )
372
373 def queryset(self, request):
Scott Baker16573d32015-07-24 15:36:02 -0700374 return CordSubscriberRoot.get_tenant_objects_by_user(request.user)
Scott Baker527326e2015-07-23 12:06:26 -0700375
Scott Baker2986b1e2015-04-21 16:59:04 -0700376admin.site.register(VOLTService, VOLTServiceAdmin)
377admin.site.register(VOLTTenant, VOLTTenantAdmin)
Scott Baker4698b922016-02-11 12:07:10 -0800378admin.site.register(VSGService, VSGServiceAdmin)
Scott Baker664bbe52016-02-11 11:08:42 -0800379admin.site.register(VSGTenant, VSGTenantAdmin)
Scott Baker932a16c2015-04-21 17:15:18 -0700380admin.site.register(VBNGService, VBNGServiceAdmin)
381admin.site.register(VBNGTenant, VBNGTenantAdmin)
Scott Baker527326e2015-07-23 12:06:26 -0700382admin.site.register(CordSubscriberRoot, CordSubscriberRootAdmin)
Scott Baker2986b1e2015-04-21 16:59:04 -0700383