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 |
Scott Baker | 67db95f | 2015-02-18 15:50:11 -0800 | [diff] [blame] | 13 | from core.admin import SingletonAdmin,SliceInline,ServiceAttrAsTabInline, ReadOnlyAwareAdmin, XOSTabularInline |
Scott Baker | 52649d6 | 2014-11-06 17:38:38 -0800 | [diff] [blame] | 14 | |
Scott Baker | 67db95f | 2015-02-18 15:50:11 -0800 | [diff] [blame] | 15 | class ServiceInline(XOSTabularInline): |
Scott Baker | 5d0fc7f | 2014-11-06 23:41:32 -0800 | [diff] [blame] | 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 Baker | 52649d6 | 2014-11-06 17:38:38 -0800 | [diff] [blame] | 24 | class 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 Baker | 5d0fc7f | 2014-11-06 23:41:32 -0800 | [diff] [blame] | 41 | class CompositionForm(forms.ModelForm): |
| 42 | model = Composition |
| 43 | class Media: |
| 44 | js = ('/static/js/menu-sort-2.js',) |
| 45 | |
Scott Baker | 52649d6 | 2014-11-06 17:38:38 -0800 | [diff] [blame] | 46 | class CompositionAdmin(ReadOnlyAwareAdmin): |
| 47 | list_display = ('backend_status_icon', 'name' ) |
| 48 | list_display_links = ('backend_status_icon', 'name' ) |
Scott Baker | 5d0fc7f | 2014-11-06 23:41:32 -0800 | [diff] [blame] | 49 | form = CompositionForm |
Scott Baker | 52649d6 | 2014-11-06 17:38:38 -0800 | [diff] [blame] | 50 | |
| 51 | fields = ('backend_status_text', 'name') |
| 52 | readonly_fields = ('backend_status_text', ) |
| 53 | user_readonly_fields = ('name',) |
| 54 | |
Scott Baker | 5d0fc7f | 2014-11-06 23:41:32 -0800 | [diff] [blame] | 55 | inlines = [ServiceInline] |
| 56 | |
Scott Baker | 52649d6 | 2014-11-06 17:38:38 -0800 | [diff] [blame] | 57 | class 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 | |
| 65 | admin.site.register(CompositionService, CompositionServiceAdmin) |
| 66 | admin.site.register(Composition, CompositionAdmin) |
| 67 | admin.site.register(EndUser, EndUserAdmin) |
| 68 | |