Scott Baker | 52649d6 | 2014-11-06 17:38:38 -0800 | [diff] [blame^] | 1 | from django.contrib import admin |
| 2 | |
| 3 | from servcomp.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.admin import SingletonAdmin,SliceInline,ServiceAttrAsTabInline, ReadOnlyAwareAdmin, PlStackTabularInline |
| 14 | |
| 15 | class CompositionServiceAdmin(SingletonAdmin): |
| 16 | model = CompositionService |
| 17 | verbose_name = "Composition Service" |
| 18 | verbose_name_plural = "Composition Service" |
| 19 | list_display = ("backend_status_icon", "name","enabled") |
| 20 | list_display_links = ('backend_status_icon', 'name', ) |
| 21 | fieldsets = [(None, {'fields': ['backend_status_text', 'name','enabled','versionNumber', 'description'], 'classes':['suit-tab suit-tab-general']})] |
| 22 | readonly_fields = ('backend_status_text', ) |
| 23 | inlines = [SliceInline,ServiceAttrAsTabInline] |
| 24 | |
| 25 | user_readonly_fields = ["name", "enabled", "versionNumber", "description"] |
| 26 | |
| 27 | suit_form_tabs =(('general', 'Composition Service Details'), |
| 28 | ('slices','Slices'), |
| 29 | ('serviceattrs','Additional Attributes'), |
| 30 | ) |
| 31 | |
| 32 | class CompositionAdmin(ReadOnlyAwareAdmin): |
| 33 | list_display = ('backend_status_icon', 'name' ) |
| 34 | list_display_links = ('backend_status_icon', 'name' ) |
| 35 | |
| 36 | fields = ('backend_status_text', 'name') |
| 37 | readonly_fields = ('backend_status_text', ) |
| 38 | user_readonly_fields = ('name',) |
| 39 | |
| 40 | class EndUserAdmin(ReadOnlyAwareAdmin): |
| 41 | list_display = ('backend_status_icon', 'email', 'macAddress', 'composition' ) |
| 42 | list_display_links = ('backend_status_icon', 'email' ) |
| 43 | |
| 44 | fields = ('backend_status_text', 'email', 'firstName', 'lastName', 'macAddress', 'composition') |
| 45 | readonly_fields = ('backend_status_text', ) |
| 46 | user_readonly_fields = ('email', 'firstName', 'lastName', 'macAddress') |
| 47 | |
| 48 | admin.site.register(CompositionService, CompositionServiceAdmin) |
| 49 | admin.site.register(Composition, CompositionAdmin) |
| 50 | admin.site.register(EndUser, EndUserAdmin) |
| 51 | |