readonly support for HPC admin
diff --git a/planetstack/hpc/admin.py b/planetstack/hpc/admin.py
index f574ec1..ee9e42b 100644
--- a/planetstack/hpc/admin.py
+++ b/planetstack/hpc/admin.py
@@ -10,43 +10,75 @@
from django.utils import timezone
from django.contrib.contenttypes import generic
from suit.widgets import LinkedSelect
+from core.admin import SingletonAdmin,SliceInline,ServiceAttrAsTabInline, SliceROInline,ServiceAttrAsTabROInline, ReadOnlyAwareAdmin, PlStackTabularInline, ReadOnlyTabularInline
-#class HPCRRBaseAdmin(admin.ModelAdmin):
- #exclude = ['enacted']
+class HpcServiceAdmin(SingletonAdmin):
+ model = HpcService
+ verbose_name = "HPC Service"
+ verbose_name_plural = "HPC Service"
+ list_display = ("name","enabled")
+ fieldsets = [(None, {'fields': ['name','enabled','versionNumber', 'description'], 'classes':['suit-tab suit-tab-general']})]
+ inlines = [SliceInline,ServiceAttrAsTabInline]
-class CDNPrefixInline(admin.TabularInline):
+ user_readonly_fields = ["name", "enabled", "versionNumber", "description"]
+ user_readonly_inlines = [SliceROInline, ServiceAttrAsTabROInline]
+
+ suit_form_tabs =(('general', 'HPC Service Details'),
+ ('slices','Slices'),
+ ('serviceattrs','Additional Attributes'),
+ )
+
+class CDNPrefixInline(PlStackTabularInline):
model = CDNPrefix
extra = 0
suit_classes = 'suit-tab suit-tab-prefixes'
-class ContentProviderInline(admin.TabularInline):
+class CDNPrefixROInline(ReadOnlyTabularInline):
+ model = CDNPrefix
+ extra = 0
+ suit_classes = 'suit-tab suit-tab-prefixes'
+
+class ContentProviderInline(PlStackTabularInline):
model = ContentProvider
extra = 0
suit_classes = 'suit-tab suit-tab-cps'
-class OriginServerAdmin(admin.ModelAdmin):
+class ContentProviderROInline(ReadOnlyTabularInline):
+ model = ContentProvider
+ extra = 0
+ suit_classes = 'suit-tab suit-tab-cps'
+
+class OriginServerAdmin(ReadOnlyAwareAdmin):
list_display = ('url','protocol','redirects','contentProvider','authenticated','enabled' )
+ user_readonly_fields = ('url','protocol','redirects','contentProvider','authenticated','enabled','origin_server_id','description','redirects','authenticated' )
+
class ContentProviderForm(forms.ModelForm):
class Meta:
widgets = {
'serviceProvider' : LinkedSelect
}
-class ContentProviderAdmin(admin.ModelAdmin):
+class ContentProviderAdmin(ReadOnlyAwareAdmin):
form = ContentProviderForm
list_display = ('name','description','enabled' )
fieldsets = [ (None, {'fields': ['name','enabled','description','serviceProvider','users'], 'classes':['suit-tab suit-tab-general']})]
inlines = [CDNPrefixInline]
+ user_readonly_fields = ('name','description','enabled','serviceProvider','users')
+ user_readonly_inlines = [CDNPrefixROInline]
+
suit_form_tabs = (('general','Details'),('prefixes','CDN Prefixes'))
-class ServiceProviderAdmin(admin.ModelAdmin):
+class ServiceProviderAdmin(ReadOnlyAwareAdmin):
list_display = ('name', 'description', 'enabled')
fieldsets = [
(None, {'fields': ['name','description','enabled'], 'classes':['suit-tab suit-tab-general']})]
-#, ('Content Providers', {'fields':['contentProviders'],'classes':['suit-tab suit-tab-cps']})]
+#, ('Content Providers', {'fields':['contentProviders'],'classes':['suit-tab suit-tab-cps']})]
+
+ user_readonly_fields = ('name', 'description', 'enabled')
+ user_readonly_inlines = [ContentProviderROInline]
suit_form_tabs = (('general','Details'),('cps','Content Providers'))
inlines = [ContentProviderInline]
@@ -57,27 +89,30 @@
'contentProvider' : LinkedSelect
}
-class CDNPrefixAdmin(admin.ModelAdmin):
+class CDNPrefixAdmin(ReadOnlyAwareAdmin):
form = CDNPrefixForm
list_display = ['prefix','contentProvider']
+ user_readonly_fields = ['prefix','contentProvider', "cdn_prefix_id", "description", "defaultOriginServer", "enabled"]
-class SiteMapAdmin(admin.ModelAdmin):
+class SiteMapAdmin(ReadOnlyAwareAdmin):
model = SiteMap
verbose_name = "Site Map"
verbose_name_plural = "Site Map"
list_display = ("name", "contentProvider", "serviceProvider")
+ user_readonly_fields = ("name", "contentProvider", "serviceProvider", "description", "map")
-class AccessMapAdmin(admin.ModelAdmin):
+class AccessMapAdmin(ReadOnlyAwareAdmin):
model = AccessMap
verbose_name = "Access Map"
verbose_name_plural = "Access Map"
list_display = ("name", "contentProvider")
+ user_readonly_fields = ("name", "contentProvider", "description", "map")
admin.site.register(ServiceProvider, ServiceProviderAdmin)
admin.site.register(ContentProvider, ContentProviderAdmin)
admin.site.register(CDNPrefix, CDNPrefixAdmin)
admin.site.register(OriginServer,OriginServerAdmin)
-admin.site.register(HpcService)
+admin.site.register(HpcService, HpcServiceAdmin)
admin.site.register(SiteMap, SiteMapAdmin)
admin.site.register(AccessMap, AccessMapAdmin)