blob: 84e0ecde373f610cedc44029f77ba4ff5087c0b5 [file] [log] [blame]
Scott Baker4eb615b2017-05-05 16:55:22 -07001from django.contrib import admin
2
3#from services.volt.models import *
4from services.rcord.models import *
5from django import forms
6from django.utils.safestring import mark_safe
7from django.contrib.auth.admin import UserAdmin
8from django.contrib.admin.widgets import FilteredSelectMultiple
9from django.contrib.auth.forms import ReadOnlyPasswordHashField
10from django.contrib.auth.signals import user_logged_in
11from django.utils import timezone
12from django.contrib.contenttypes import generic
13from suit.widgets import LinkedSelect
14from core.admin import ServiceAppAdmin,SliceInline,ServiceAttrAsTabInline, ReadOnlyAwareAdmin, XOSTabularInline, ServicePrivilegeInline, TenantRootTenantInline, TenantRootPrivilegeInline
15from core.middleware import get_request
16
17from functools import update_wrapper
18from django.contrib.admin.views.main import ChangeList
19from django.core.urlresolvers import reverse
20from django.contrib.admin.utils import quote
21
22#class VOLTTenantInline(XOSTabularInline):
23# model = VOLTTenant
24# fields = ['provider_service', 'subscriber_root', 'service_specific_id']
25# readonly_fields = ['provider_service', 'subscriber_root', 'service_specific_id']
26# extra = 0
27# max_num = 0
28# suit_classes = 'suit-tab suit-tab-volttenants'
29# fk_name = 'subscriber_root'
30# verbose_name = 'subscribed tenant'
31# verbose_name_plural = 'subscribed tenants'
32#
33# @property
34# def selflink_reverse_path(self):
35# return "admin:cord_volttenant_change"
36
37class CordSubscriberRootForm(forms.ModelForm):
38 def __init__(self,*args,**kwargs):
39 super (CordSubscriberRootForm,self ).__init__(*args,**kwargs)
40 self.fields['kind'].widget.attrs['readonly'] = True
41 if (not self.instance) or (not self.instance.pk):
42 # default fields for an 'add' form
43 self.fields['kind'].initial = CORD_SUBSCRIBER_KIND
44
45 def save(self, commit=True):
46 return super(CordSubscriberRootForm, self).save(commit=commit)
47
48 class Meta:
49 model = CordSubscriberRoot
50 fields = '__all__'
51
52class CordSubscriberRootAdmin(ReadOnlyAwareAdmin):
53 list_display = ('backend_status_icon', 'id', 'name', )
54 list_display_links = ('backend_status_icon', 'id', 'name', )
55 fieldsets = [ (None, {'fields': ['backend_status_text', 'kind', 'name', 'service_specific_id', # 'service_specific_attribute',
56 'url_filter_level', "uplink_speed", "downlink_speed", "status", "enable_uverse", "cdn_enable"],
57 'classes':['suit-tab suit-tab-general']})]
58 readonly_fields = ('backend_status_text', 'service_specific_attribute',)
59 form = CordSubscriberRootForm
60 inlines = (TenantRootPrivilegeInline) # VOLTTenantInline
61
62 suit_form_tabs =(('general', 'Cord Subscriber Root Details'),
63# ('volttenants','VOLT Tenancy'),
64 ('tenantrootprivileges','Privileges')
65 )
66
67 def get_queryset(self, request):
68 return CordSubscriberRoot.get_tenant_objects_by_user(request.user)
69
70admin.site.register(CordSubscriberRoot, CordSubscriberRootAdmin)