blob: dc26b1e9cf46d2fd93afabb65920bbff46e72b8a [file] [log] [blame]
Scott Bakerc97b56d2014-11-06 17:38:38 -08001from django.contrib import admin
2
3from servcomp.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.admin import SingletonAdmin,SliceInline,ServiceAttrAsTabInline, ReadOnlyAwareAdmin, PlStackTabularInline
14
Scott Baker90adeca2014-11-06 23:41:32 -080015class ServiceInline(PlStackTabularInline):
16 model = CompositionServiceThrough
17 verbose_name = "Service"
18 verbose_name_plural = "Services"
19 extra = 0
20 #suit_classes = 'suit-tab suit-tab-general'
21 fields = ('backend_status_icon', 'service', 'order')
22 readonly_fields = ('backend_status_icon',)
23
Scott Bakerc97b56d2014-11-06 17:38:38 -080024class CompositionServiceAdmin(SingletonAdmin):
25 model = CompositionService
26 verbose_name = "Composition Service"
27 verbose_name_plural = "Composition Service"
28 list_display = ("backend_status_icon", "name","enabled")
29 list_display_links = ('backend_status_icon', 'name', )
30 fieldsets = [(None, {'fields': ['backend_status_text', 'name','enabled','versionNumber', 'description'], 'classes':['suit-tab suit-tab-general']})]
31 readonly_fields = ('backend_status_text', )
32 inlines = [SliceInline,ServiceAttrAsTabInline]
33
34 user_readonly_fields = ["name", "enabled", "versionNumber", "description"]
35
36 suit_form_tabs =(('general', 'Composition Service Details'),
37 ('slices','Slices'),
38 ('serviceattrs','Additional Attributes'),
39 )
40
Scott Baker90adeca2014-11-06 23:41:32 -080041class CompositionForm(forms.ModelForm):
42 model = Composition
43 class Media:
44 js = ('/static/js/menu-sort-2.js',)
45
Scott Bakerc97b56d2014-11-06 17:38:38 -080046class CompositionAdmin(ReadOnlyAwareAdmin):
47 list_display = ('backend_status_icon', 'name' )
48 list_display_links = ('backend_status_icon', 'name' )
Scott Baker90adeca2014-11-06 23:41:32 -080049 form = CompositionForm
Scott Bakerc97b56d2014-11-06 17:38:38 -080050
51 fields = ('backend_status_text', 'name')
52 readonly_fields = ('backend_status_text', )
53 user_readonly_fields = ('name',)
54
Scott Baker90adeca2014-11-06 23:41:32 -080055 inlines = [ServiceInline]
56
Scott Bakerc97b56d2014-11-06 17:38:38 -080057class EndUserAdmin(ReadOnlyAwareAdmin):
58 list_display = ('backend_status_icon', 'email', 'macAddress', 'composition' )
59 list_display_links = ('backend_status_icon', 'email' )
60
61 fields = ('backend_status_text', 'email', 'firstName', 'lastName', 'macAddress', 'composition')
62 readonly_fields = ('backend_status_text', )
63 user_readonly_fields = ('email', 'firstName', 'lastName', 'macAddress')
64
65admin.site.register(CompositionService, CompositionServiceAdmin)
66admin.site.register(Composition, CompositionAdmin)
67admin.site.register(EndUser, EndUserAdmin)
68