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 | |
Scott Baker | 5349108 | 2014-03-13 23:15:19 -0700 | [diff] [blame] | 64 | class SiteMapAdmin(admin.ModelAdmin): |
| 65 | model = SiteMap |
| 66 | verbose_name = "Site Map" |
| 67 | verbose_name_plural = "Site Map" |
| 68 | list_display = ("name", "contentProvider", "serviceProvider") |
| 69 | |
| 70 | class AccessMapAdmin(admin.ModelAdmin): |
| 71 | model = AccessMap |
| 72 | verbose_name = "Access Map" |
| 73 | verbose_name_plural = "Access Map" |
| 74 | list_display = ("name", "contentProvider") |
| 75 | |
Siobhan Tully | bfd11dc | 2013-09-03 12:59:24 -0400 | [diff] [blame] | 76 | admin.site.register(ServiceProvider, ServiceProviderAdmin) |
| 77 | admin.site.register(ContentProvider, ContentProviderAdmin) |
| 78 | admin.site.register(CDNPrefix, CDNPrefixAdmin) |
| 79 | admin.site.register(OriginServer,OriginServerAdmin) |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 80 | admin.site.register(HpcService) |
Scott Baker | 5349108 | 2014-03-13 23:15:19 -0700 | [diff] [blame] | 81 | admin.site.register(SiteMap, SiteMapAdmin) |
| 82 | admin.site.register(AccessMap, AccessMapAdmin) |
Siobhan Tully | bfd11dc | 2013-09-03 12:59:24 -0400 | [diff] [blame] | 83 | |