blob: df73ebba34e0ee99ee3682709675c2facaca67bf [file] [log] [blame]
Scott Baker46831592016-06-20 17:32:04 -07001from django.contrib import admin
2
3from services.fabric.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
13from core.models import AddressPool
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
22class FabricServiceForm(forms.ModelForm):
23 def __init__(self,*args,**kwargs):
24 super (FabricServiceForm,self ).__init__(*args,**kwargs)
25
26 def save(self, commit=True):
27 return super(FabricServiceForm, self).save(commit=commit)
28
29 class Meta:
30 model = FabricService
Zack Williams6e786a32016-06-27 08:24:06 -070031 fields = '__all__'
Scott Baker46831592016-06-20 17:32:04 -070032
33class FabricServiceAdmin(ReadOnlyAwareAdmin):
34 model = FabricService
35 verbose_name = "Fabric Service"
36 verbose_name_plural = "Fabric Services"
37 list_display = ("backend_status_icon", "name", "enabled")
38 list_display_links = ('backend_status_icon', 'name', )
39 fieldsets = [(None, {'fields': ['backend_status_text', 'name','enabled','versionNumber', 'description', "view_url", "icon_url", "autoconfig", ],
40 'classes':['suit-tab suit-tab-general']})]
41 readonly_fields = ('backend_status_text', )
42 inlines = [SliceInline,ServiceAttrAsTabInline,ServicePrivilegeInline]
43 form = FabricServiceForm
44
45 extracontext_registered_admins = True
46
47 user_readonly_fields = ["name", "enabled", "versionNumber", "description"]
48
49 suit_form_tabs =(('general', 'Fabric Service Details'),
50 ('administration', 'Administration'),
51 #('tools', 'Tools'),
52 ('slices','Slices'),
53 ('serviceattrs','Additional Attributes'),
54 ('serviceprivileges','Privileges'),
55 )
56
57 suit_form_includes = (('fabricadmin.html', 'top', 'administration'),
58 )
59
60 def queryset(self, request):
61 return FabricService.get_service_objects_by_user(request.user)
62
63admin.site.register(FabricService, FabricServiceAdmin)