Siobhan Tully | bfd11dc | 2013-09-03 12:59:24 -0400 | [diff] [blame] | 1 | from django.contrib import admin |
| 2 | |
| 3 | from hpc.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 | |
| 14 | #class HPCRRBaseAdmin(admin.ModelAdmin): |
| 15 | #exclude = ['enacted'] |
| 16 | |
| 17 | class CDNPrefixInline(admin.TabularInline): |
| 18 | model = CDNPrefix |
| 19 | extra = 0 |
| 20 | suit_classes = 'suit-tab suit-tab-prefixes' |
| 21 | |
| 22 | class ContentProviderInline(admin.TabularInline): |
| 23 | model = ContentProvider |
| 24 | extra = 0 |
| 25 | suit_classes = 'suit-tab suit-tab-cps' |
| 26 | |
| 27 | class OriginServerAdmin(admin.ModelAdmin): |
| 28 | list_display = ('url','protocol','redirects','contentProvider','authenticated','enabled' ) |
| 29 | |
| 30 | class ContentProviderForm(forms.ModelForm): |
| 31 | class Meta: |
| 32 | widgets = { |
| 33 | 'serviceProvider' : LinkedSelect |
| 34 | } |
| 35 | |
| 36 | class ContentProviderAdmin(admin.ModelAdmin): |
| 37 | form = ContentProviderForm |
| 38 | list_display = ('name','description','enabled' ) |
| 39 | fieldsets = [ (None, {'fields': ['name','enabled','description','serviceProvider','users'], 'classes':['suit-tab suit-tab-general']})] |
| 40 | |
| 41 | inlines = [CDNPrefixInline] |
| 42 | |
| 43 | suit_form_tabs = (('general','Details'),('prefixes','CDN Prefixes')) |
| 44 | |
| 45 | class ServiceProviderAdmin(admin.ModelAdmin): |
| 46 | list_display = ('name', 'description', 'enabled') |
| 47 | fieldsets = [ |
| 48 | (None, {'fields': ['name','description','enabled'], 'classes':['suit-tab suit-tab-general']})] |
| 49 | #, ('Content Providers', {'fields':['contentProviders'],'classes':['suit-tab suit-tab-cps']})] |
| 50 | |
| 51 | suit_form_tabs = (('general','Details'),('cps','Content Providers')) |
| 52 | inlines = [ContentProviderInline] |
| 53 | |
| 54 | class CDNPrefixForm(forms.ModelForm): |
| 55 | class Meta: |
| 56 | widgets = { |
| 57 | 'contentProvider' : LinkedSelect |
| 58 | } |
| 59 | |
| 60 | class CDNPrefixAdmin(admin.ModelAdmin): |
| 61 | form = CDNPrefixForm |
| 62 | list_display = ['prefix','contentProvider'] |
| 63 | |
| 64 | admin.site.register(ServiceProvider, ServiceProviderAdmin) |
| 65 | admin.site.register(ContentProvider, ContentProviderAdmin) |
| 66 | admin.site.register(CDNPrefix, CDNPrefixAdmin) |
| 67 | admin.site.register(OriginServer,OriginServerAdmin) |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 68 | admin.site.register(HpcService) |
Siobhan Tully | bfd11dc | 2013-09-03 12:59:24 -0400 | [diff] [blame] | 69 | |