Scott Baker | 4683159 | 2016-06-20 17:32:04 -0700 | [diff] [blame] | 1 | from django.contrib import admin |
| 2 | |
| 3 | from services.fabric.models import * |
| 4 | from django import forms |
| 5 | from django.utils.safestring import mark_safe |
| 6 | from django.contrib.auth.admin import UserAdmin |
| 7 | from django.contrib.admin.widgets import FilteredSelectMultiple |
| 8 | from django.contrib.auth.forms import ReadOnlyPasswordHashField |
| 9 | from django.contrib.auth.signals import user_logged_in |
| 10 | from django.utils import timezone |
| 11 | from django.contrib.contenttypes import generic |
| 12 | from suit.widgets import LinkedSelect |
| 13 | from core.models import AddressPool |
| 14 | from core.admin import ServiceAppAdmin,SliceInline,ServiceAttrAsTabInline, ReadOnlyAwareAdmin, XOSTabularInline, ServicePrivilegeInline, TenantRootTenantInline, TenantRootPrivilegeInline |
| 15 | from core.middleware import get_request |
| 16 | |
| 17 | from functools import update_wrapper |
| 18 | from django.contrib.admin.views.main import ChangeList |
| 19 | from django.core.urlresolvers import reverse |
| 20 | from django.contrib.admin.utils import quote |
| 21 | |
| 22 | class 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 Williams | 6e786a3 | 2016-06-27 08:24:06 -0700 | [diff] [blame] | 31 | fields = '__all__' |
Scott Baker | 4683159 | 2016-06-20 17:32:04 -0700 | [diff] [blame] | 32 | |
| 33 | class 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 | |
| 63 | admin.site.register(FabricService, FabricServiceAdmin) |