blob: a21a58be73a0568d49e345cfed2e9bf4d290cc12 [file] [log] [blame]
Scott Baker2986b1e2015-04-21 16:59:04 -07001from django.contrib import admin
2
3from cord.models import *
4from 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 Baker559be722015-05-15 09:08:19 -070013from core.admin import ServiceAppAdmin,SliceInline,ServiceAttrAsTabInline, ReadOnlyAwareAdmin, XOSTabularInline, ServicePrivilegeInline
Scott Baker2986b1e2015-04-21 16:59:04 -070014
15from functools import update_wrapper
16from django.contrib.admin.views.main import ChangeList
17from django.core.urlresolvers import reverse
18from django.contrib.admin.utils import quote
19
Scott Baker932a16c2015-04-21 17:15:18 -070020#-----------------------------------------------------------------------------
21# vOLT
22#-----------------------------------------------------------------------------
Scott Baker2986b1e2015-04-21 16:59:04 -070023
24class VOLTServiceAdmin(ReadOnlyAwareAdmin):
25 model = VOLTService
26 verbose_name = "vOLT Service"
27 verbose_name_plural = "vOLT Service"
28 list_display = ("backend_status_icon", "name", "enabled")
29 list_display_links = ('backend_status_icon', 'name', )
Scott Baker932a16c2015-04-21 17:15:18 -070030 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 -070031 readonly_fields = ('backend_status_text', )
Scott Baker559be722015-05-15 09:08:19 -070032 inlines = [SliceInline,ServiceAttrAsTabInline,ServicePrivilegeInline]
Scott Baker2986b1e2015-04-21 16:59:04 -070033
34 extracontext_registered_admins = True
35
36 user_readonly_fields = ["name", "enabled", "versionNumber", "description"]
37
38 suit_form_tabs =(('general', 'vOLT Service Details'),
39 ('administration', 'Administration'),
40 #('tools', 'Tools'),
41 ('slices','Slices'),
42 ('serviceattrs','Additional Attributes'),
Scott Baker559be722015-05-15 09:08:19 -070043 ('serviceprivileges','Privileges'),
Scott Baker2986b1e2015-04-21 16:59:04 -070044 )
45
46 suit_form_includes = (('voltadmin.html', 'top', 'administration'),
47 ) #('hpctools.html', 'top', 'tools') )
48
49 def queryset(self, request):
50 return VOLTService.get_service_objects()
51
52class VOLTTenantForm(forms.ModelForm):
53 def __init__(self,*args,**kwargs):
54 super (VOLTTenantForm,self ).__init__(*args,**kwargs)
55 self.fields['kind'].default = "vOLT"
56 self.fields['kind'].widget.attrs['readonly'] = True
57 self.fields['provider_service'].queryset = VOLTService.get_service_objects().all()
58
59 class Meta:
60 model = VOLTTenant
61
62class VOLTTenantAdmin(ReadOnlyAwareAdmin):
Scott Baker932a16c2015-04-21 17:15:18 -070063 list_display = ('backend_status_icon', 'id', 'service_specific_id', 'vlan_id' )
64 list_display_links = ('backend_status_icon', 'id')
Scott Baker2986b1e2015-04-21 16:59:04 -070065 fieldsets = [ (None, {'fields': ['backend_status_text', 'kind', 'provider_service', 'service_specific_id', 'service_specific_attribute',], 'classes':['suit-tab suit-tab-general']})]
66 readonly_fields = ('backend_status_text', )
67 form = VOLTTenantForm
68
69 suit_form_tabs = (('general','Details'),)
70
71 def queryset(self, request):
72 return VOLTTenant.get_tenant_objects()
73
Scott Baker932a16c2015-04-21 17:15:18 -070074#-----------------------------------------------------------------------------
75# vCPE
76#-----------------------------------------------------------------------------
77
78class VCPEServiceAdmin(ReadOnlyAwareAdmin):
79 model = VCPEService
80 verbose_name = "vCPE Service"
81 verbose_name_plural = "vCPE Service"
82 list_display = ("backend_status_icon", "name", "enabled")
83 list_display_links = ('backend_status_icon', 'name', )
84 fieldsets = [(None, {'fields': ['backend_status_text', 'name','enabled','versionNumber', 'description', "view_url","icon_url" ], 'classes':['suit-tab suit-tab-general']})]
85 readonly_fields = ('backend_status_text', )
Scott Baker559be722015-05-15 09:08:19 -070086 inlines = [SliceInline,ServiceAttrAsTabInline,ServicePrivilegeInline]
Scott Baker932a16c2015-04-21 17:15:18 -070087
88 extracontext_registered_admins = True
89
90 user_readonly_fields = ["name", "enabled", "versionNumber", "description"]
91
92 suit_form_tabs =(('general', 'vCPE Service Details'),
93 ('administration', 'Administration'),
94 #('tools', 'Tools'),
95 ('slices','Slices'),
96 ('serviceattrs','Additional Attributes'),
Scott Baker559be722015-05-15 09:08:19 -070097 ('serviceprivileges','Privileges') ,
Scott Baker932a16c2015-04-21 17:15:18 -070098 )
99
100 suit_form_includes = (('vcpeadmin.html', 'top', 'administration'),
101 ) #('hpctools.html', 'top', 'tools') )
102
103 def queryset(self, request):
104 return VCPEService.get_service_objects()
105
106class VCPETenantForm(forms.ModelForm):
107 def __init__(self,*args,**kwargs):
108 super (VCPETenantForm,self ).__init__(*args,**kwargs)
109 self.fields['kind'].default = "vCPE"
110 self.fields['kind'].widget.attrs['readonly'] = True
111 self.fields['provider_service'].queryset = VCPEService.get_service_objects().all()
112
113 class Meta:
114 model = VCPETenant
115
116class VCPETenantAdmin(ReadOnlyAwareAdmin):
117 list_display = ('backend_status_icon', 'id' )
118 list_display_links = ('backend_status_icon', 'id')
119 fieldsets = [ (None, {'fields': ['backend_status_text', 'kind', 'provider_service', 'service_specific_id', 'service_specific_attribute',], 'classes':['suit-tab suit-tab-general']})]
120 readonly_fields = ('backend_status_text', )
121 form = VCPETenantForm
122
123 suit_form_tabs = (('general','Details'),)
124
125 def queryset(self, request):
126 return VCPETenant.get_tenant_objects()
127
128#-----------------------------------------------------------------------------
129# vBNG
130#-----------------------------------------------------------------------------
131
132class VBNGServiceAdmin(ReadOnlyAwareAdmin):
133 model = VBNGService
134 verbose_name = "vBNG Service"
135 verbose_name_plural = "vBNG Service"
136 list_display = ("backend_status_icon", "name", "enabled")
137 list_display_links = ('backend_status_icon', 'name', )
138 fieldsets = [(None, {'fields': ['backend_status_text', 'name','enabled','versionNumber', 'description', "view_url","icon_url" ], 'classes':['suit-tab suit-tab-general']})]
139 readonly_fields = ('backend_status_text', )
Scott Baker559be722015-05-15 09:08:19 -0700140 inlines = [SliceInline,ServiceAttrAsTabInline,ServicePrivilegeInline]
Scott Baker932a16c2015-04-21 17:15:18 -0700141
142 extracontext_registered_admins = True
143
144 user_readonly_fields = ["name", "enabled", "versionNumber", "description"]
145
146 suit_form_tabs =(('general', 'vBNG Service Details'),
147 ('administration', 'Administration'),
148 #('tools', 'Tools'),
149 ('slices','Slices'),
150 ('serviceattrs','Additional Attributes'),
Scott Baker559be722015-05-15 09:08:19 -0700151 ('serviceprivileges','Privileges'),
Scott Baker932a16c2015-04-21 17:15:18 -0700152 )
153
154 suit_form_includes = (('vbngadmin.html', 'top', 'administration'),
155 ) #('hpctools.html', 'top', 'tools') )
156
157 def queryset(self, request):
158 return VBNGService.get_service_objects()
159
160class VBNGTenantForm(forms.ModelForm):
161 def __init__(self,*args,**kwargs):
162 super (VBNGTenantForm,self ).__init__(*args,**kwargs)
163 self.fields['kind'].default = "vBNG"
164 self.fields['kind'].widget.attrs['readonly'] = True
165 self.fields['provider_service'].queryset = VBNGService.get_service_objects().all()
166
167 class Meta:
168 model = VBNGTenant
169
170class VBNGTenantAdmin(ReadOnlyAwareAdmin):
171 list_display = ('backend_status_icon', 'id' )
172 list_display_links = ('backend_status_icon', 'id')
173 fieldsets = [ (None, {'fields': ['backend_status_text', 'kind', 'provider_service', 'service_specific_id', 'service_specific_attribute',], 'classes':['suit-tab suit-tab-general']})]
174 readonly_fields = ('backend_status_text', )
175 form = VBNGTenantForm
176
177 suit_form_tabs = (('general','Details'),)
178
179 def queryset(self, request):
180 return VBNGTenant.get_tenant_objects()
181
Scott Baker2986b1e2015-04-21 16:59:04 -0700182admin.site.register(VOLTService, VOLTServiceAdmin)
183admin.site.register(VOLTTenant, VOLTTenantAdmin)
Scott Baker932a16c2015-04-21 17:15:18 -0700184admin.site.register(VCPEService, VCPEServiceAdmin)
185admin.site.register(VCPETenant, VCPETenantAdmin)
186admin.site.register(VBNGService, VBNGServiceAdmin)
187admin.site.register(VBNGTenant, VBNGTenantAdmin)
Scott Baker2986b1e2015-04-21 16:59:04 -0700188