Scott Baker | c3ce3e7 | 2016-06-20 17:35:19 -0700 | [diff] [blame] | 1 | from django.contrib import admin |
| 2 | |
| 3 | from django import forms |
| 4 | from django.utils.safestring import mark_safe |
| 5 | from django.contrib.auth.admin import UserAdmin |
| 6 | from django.contrib.admin.widgets import FilteredSelectMultiple |
| 7 | from django.contrib.auth.forms import ReadOnlyPasswordHashField |
| 8 | from django.contrib.auth.signals import user_logged_in |
| 9 | from django.utils import timezone |
| 10 | from django.contrib.contenttypes import generic |
| 11 | from suit.widgets import LinkedSelect |
Scott Baker | d949b62 | 2017-07-18 12:10:35 -0700 | [diff] [blame^] | 12 | from core.admin import ServiceAppAdmin,SliceInline,ServiceAttrAsTabInline, ReadOnlyAwareAdmin, XOSTabularInline, ServicePrivilegeInline |
Scott Baker | c3ce3e7 | 2016-06-20 17:35:19 -0700 | [diff] [blame] | 13 | from core.middleware import get_request |
| 14 | |
| 15 | from services.vtn.models import * |
| 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 | |
Scott Baker | c3ce3e7 | 2016-06-20 17:35:19 -0700 | [diff] [blame] | 22 | class VTNServiceAdmin(ReadOnlyAwareAdmin): |
| 23 | model = VTNService |
Scott Baker | c3ce3e7 | 2016-06-20 17:35:19 -0700 | [diff] [blame] | 24 | verbose_name = "VTN Service" |
| 25 | verbose_name_plural = "VTN Service" |
| 26 | list_display = ("backend_status_icon", "name", "enabled") |
| 27 | list_display_links = ('backend_status_icon', 'name', ) |
| 28 | fieldsets = [(None, {'fields': ['backend_status_text', 'name','enabled','versionNumber','description',"view_url","icon_url", |
Scott Baker | ff01668 | 2016-11-28 09:53:13 -0800 | [diff] [blame] | 29 | 'privateGatewayMac', 'localManagementIp', 'ovsdbPort', 'sshPort', 'sshUser', 'sshKeyFile', 'mgmtSubnetBits', 'xosEndpoint', 'xosUser', 'xosPassword', 'vtnAPIVersion', 'controllerPort' ], 'classes':['suit-tab suit-tab-general']})] |
Scott Baker | c3ce3e7 | 2016-06-20 17:35:19 -0700 | [diff] [blame] | 30 | readonly_fields = ('backend_status_text', ) |
| 31 | inlines = [SliceInline,ServiceAttrAsTabInline,ServicePrivilegeInline] |
| 32 | |
| 33 | extracontext_registered_admins = True |
| 34 | |
| 35 | user_readonly_fields = ["name", "enabled", "versionNumber", "description"] |
| 36 | |
| 37 | suit_form_tabs =(('general', 'VTN Service Details'), |
| 38 | # ('administration', 'Administration'), |
| 39 | ('slices','Slices'), |
| 40 | ('serviceattrs','Additional Attributes'), |
| 41 | ('serviceprivileges','Privileges'), |
| 42 | ) |
| 43 | |
| 44 | suit_form_includes = ( # ('vtnadmin.html', 'top', 'administration'), |
| 45 | ) #('hpctools.html', 'top', 'tools') ) |
| 46 | |
Zack Williams | abe24da | 2016-06-27 13:09:00 -0700 | [diff] [blame] | 47 | def get_queryset(self, request): |
Scott Baker | cd2db8c | 2017-05-25 09:07:19 -0700 | [diff] [blame] | 48 | return VTNService.select_by_user(request.user) |
Scott Baker | c3ce3e7 | 2016-06-20 17:35:19 -0700 | [diff] [blame] | 49 | |
| 50 | admin.site.register(VTNService, VTNServiceAdmin) |