Mercurial > public > madeira
diff band/admin.py @ 71:e2868ad47a1e
For Django 1.4, using the new manage.py.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 14 Apr 2012 16:40:29 -0500 |
parents | madeira/band/admin.py@0176eca97d1d |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/band/admin.py Sat Apr 14 16:40:29 2012 -0500 @@ -0,0 +1,83 @@ +""" +Automatic admin definitions for the band models. + +""" +from django.contrib import admin + +from band.models import Album +from band.models import AlbumMerchant +from band.models import AlbumTrack +from band.models import Gear +from band.models import LabelRelease +from band.models import Member +from band.models import Merchandise +from band.models import RecordLabel + + +class GearInline(admin.TabularInline): + model = Gear + + +class GearAdmin(admin.ModelAdmin): + list_display = ['item', 'member'] + list_filter = ['member'] + + +class MemberAdmin(admin.ModelAdmin): + list_display = ['name', 'instrument', 'is_active'] + inlines = [GearInline] + + +class AlbumTrackInline(admin.TabularInline): + model = AlbumTrack + + +class AlbumTrackAdmin(admin.ModelAdmin): + list_display = ['track_name', 'album'] + list_filter = ['album'] + + +class LabelReleaseInline(admin.TabularInline): + model = LabelRelease + + +class LabelReleaseAdmin(admin.ModelAdmin): + list_display = ['catalog_number', 'album', 'record_label', 'release_date'] + list_filter = ['record_label', 'album'] + + +class RecordLabelAdmin(admin.ModelAdmin): + inlines = [LabelReleaseInline] + + +class AlbumMerchantInline(admin.TabularInline): + model = AlbumMerchant + + +class AlbumMerchantAdmin(admin.ModelAdmin): + list_display = ['name', 'album'] + list_filter = ['album'] + + +class AlbumAdmin(admin.ModelAdmin): + save_on_top = True + inlines = [ + AlbumTrackInline, + LabelReleaseInline, + AlbumMerchantInline, + ] + + +class MerchandiseAdmin(admin.ModelAdmin): + list_display = ['name', 'price', 'in_stock'] + list_filter = ['in_stock'] + + +admin.site.register(Gear, GearAdmin) +admin.site.register(Member, MemberAdmin) +admin.site.register(AlbumTrack, AlbumTrackAdmin) +admin.site.register(LabelRelease, LabelReleaseAdmin) +admin.site.register(RecordLabel, RecordLabelAdmin) +admin.site.register(AlbumMerchant, AlbumMerchantAdmin) +admin.site.register(Album, AlbumAdmin) +admin.site.register(Merchandise, MerchandiseAdmin)