blob: 1289587d2d721aa492348ab54c5977bc42625dbd [file] [log] [blame]
Andrea Campanella45536f72017-02-23 15:20:06 +01001from 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
22#TODO this class has to be redone according to vEE needs
23class VEEServiceForm(forms.ModelForm):
24 def __init__(self,*args,**kwargs):
25 super (VEEServiceForm,self ).__init__(*args,**kwargs)
26
27 def save(self, commit=True):
28 return super(VEEServiceForm, self).save(commit=commit)
29
30 class Meta:
31 model = VEEService
32 fields = '__all__'
33
34class VEEServiceAdmin(ReadOnlyAwareAdmin):
35 model = VEEService
36 verbose_name = "VEE Service"
37 verbose_name_plural = "VEE Services"
38 list_display = ("backend_status_icon", "name", "enabled")
39 list_display_links = ('backend_status_icon', 'name', )
40 fieldsets = [(None, {'fields': ['backend_status_text', 'name','enabled','versionNumber', 'description', "view_url", "icon_url", "autoconfig", ],
41 'classes':['suit-tab suit-tab-general']})]
42 readonly_fields = ('backend_status_text', )
43 inlines = [SliceInline,ServiceAttrAsTabInline,ServicePrivilegeInline]
44 form = VEEServiceForm
45
46 extracontext_registered_admins = True
47
48 user_readonly_fields = ["name", "enabled", "versionNumber", "description"]
49
50 suit_form_tabs =(('general', 'VEE Service Details'),
51 ('administration', 'Administration'),
52 #('tools', 'Tools'),
53 ('slices','Slices'),
54 ('serviceattrs','Additional Attributes'),
55 ('serviceprivileges','Privileges'),
56 )
57
58 suit_form_includes = (('veeadmin.html', 'top', 'administration'),
59 )
60
61 def get_queryset(self, request):
62 return VEEService.get_service_objects_by_user(request.user)
63
64admin.site.register(VEEService, VEEServiceAdmin)