blob: d755a903fb464afcf039286965663d8493abe88a [file] [log] [blame]
Matteo Scandolo5eb20bb2017-08-08 13:05:26 -07001
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
Andrea Campanella45536f72017-02-23 15:20:06 +010017from django.contrib import admin
18
19from services.fabric.models import *
20from django import forms
21from django.utils.safestring import mark_safe
22from django.contrib.auth.admin import UserAdmin
23from django.contrib.admin.widgets import FilteredSelectMultiple
24from django.contrib.auth.forms import ReadOnlyPasswordHashField
25from django.contrib.auth.signals import user_logged_in
26from django.utils import timezone
27from django.contrib.contenttypes import generic
28from suit.widgets import LinkedSelect
29from core.models import AddressPool
30from core.admin import ServiceAppAdmin,SliceInline,ServiceAttrAsTabInline, ReadOnlyAwareAdmin, XOSTabularInline, ServicePrivilegeInline, TenantRootTenantInline, TenantRootPrivilegeInline
31from core.middleware import get_request
32
33from functools import update_wrapper
34from django.contrib.admin.views.main import ChangeList
35from django.core.urlresolvers import reverse
36from django.contrib.admin.utils import quote
37
38#TODO this class has to be redone according to vEE needs
39class VEEServiceForm(forms.ModelForm):
40 def __init__(self,*args,**kwargs):
41 super (VEEServiceForm,self ).__init__(*args,**kwargs)
42
43 def save(self, commit=True):
44 return super(VEEServiceForm, self).save(commit=commit)
45
46 class Meta:
47 model = VEEService
48 fields = '__all__'
49
50class VEEServiceAdmin(ReadOnlyAwareAdmin):
51 model = VEEService
52 verbose_name = "VEE Service"
53 verbose_name_plural = "VEE Services"
54 list_display = ("backend_status_icon", "name", "enabled")
55 list_display_links = ('backend_status_icon', 'name', )
56 fieldsets = [(None, {'fields': ['backend_status_text', 'name','enabled','versionNumber', 'description', "view_url", "icon_url", "autoconfig", ],
57 'classes':['suit-tab suit-tab-general']})]
58 readonly_fields = ('backend_status_text', )
59 inlines = [SliceInline,ServiceAttrAsTabInline,ServicePrivilegeInline]
60 form = VEEServiceForm
61
62 extracontext_registered_admins = True
63
64 user_readonly_fields = ["name", "enabled", "versionNumber", "description"]
65
66 suit_form_tabs =(('general', 'VEE Service Details'),
67 ('administration', 'Administration'),
68 #('tools', 'Tools'),
69 ('slices','Slices'),
70 ('serviceattrs','Additional Attributes'),
71 ('serviceprivileges','Privileges'),
72 )
73
74 suit_form_includes = (('veeadmin.html', 'top', 'administration'),
75 )
76
77 def get_queryset(self, request):
78 return VEEService.get_service_objects_by_user(request.user)
79
80admin.site.register(VEEService, VEEServiceAdmin)