John H. Hartman | 642bfb4 | 2014-09-22 13:35:55 -0700 | [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 | from core.admin import SingletonAdmin,SliceInline,ServiceAttrAsTabInline, ReadOnlyAwareAdmin, PlStackTabularInline |
| 14 | |
| 15 | class RRServiceAdmin(SingletonAdmin): |
| 16 | model = RRService |
| 17 | verbose_name = "RR Service" |
| 18 | verbose_name_plural = "RR 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', 'RR Service Details'), |
| 28 | ('slices','Slices'), |
| 29 | ('serviceattrs','Additional Attributes'), |
| 30 | ) |
| 31 | |
| 32 | class DNSNameInline(PlStackTabularInline): |
| 33 | model = CDNPrefix |
| 34 | extra = 0 |
| 35 | suit_classes = 'suit-tab suit-tab-prefixes' |
| 36 | fields = ('dns_name_id', 'name', 'enabled') |
| 37 | readonly_fields = ('dns_name_id',) |
| 38 | |
| 39 | class DNSNameForm(forms.ModelForm): |
| 40 | class Meta: |
| 41 | widgets = { |
| 42 | 'contentProvider' : LinkedSelect |
| 43 | } |
| 44 | |
| 45 | class DNSNameAdmin(ReadOnlyAwareAdmin): |
| 46 | form = CDNPrefixForm |
| 47 | list_display = ['name'] |
| 48 | list_display_links = ('name', ) |
| 49 | fields = ['name', 'dns_name_id', 'description', 'enabled'] |
| 50 | readonly_fields = ( ) |
| 51 | user_readonly_fields = ['name', "dns_name_id", "description", "enabled"] |
| 52 | |
| 53 | |
| 54 | admin.site.register(DNSName, DNSNameAdmin) |
| 55 | admin.site.register(RRService, RRServiceAdmin) |