comparison 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
comparison
equal deleted inserted replaced
70:f26cdda0ad8b 71:e2868ad47a1e
1 """
2 Automatic admin definitions for the band models.
3
4 """
5 from django.contrib import admin
6
7 from band.models import Album
8 from band.models import AlbumMerchant
9 from band.models import AlbumTrack
10 from band.models import Gear
11 from band.models import LabelRelease
12 from band.models import Member
13 from band.models import Merchandise
14 from band.models import RecordLabel
15
16
17 class GearInline(admin.TabularInline):
18 model = Gear
19
20
21 class GearAdmin(admin.ModelAdmin):
22 list_display = ['item', 'member']
23 list_filter = ['member']
24
25
26 class MemberAdmin(admin.ModelAdmin):
27 list_display = ['name', 'instrument', 'is_active']
28 inlines = [GearInline]
29
30
31 class AlbumTrackInline(admin.TabularInline):
32 model = AlbumTrack
33
34
35 class AlbumTrackAdmin(admin.ModelAdmin):
36 list_display = ['track_name', 'album']
37 list_filter = ['album']
38
39
40 class LabelReleaseInline(admin.TabularInline):
41 model = LabelRelease
42
43
44 class LabelReleaseAdmin(admin.ModelAdmin):
45 list_display = ['catalog_number', 'album', 'record_label', 'release_date']
46 list_filter = ['record_label', 'album']
47
48
49 class RecordLabelAdmin(admin.ModelAdmin):
50 inlines = [LabelReleaseInline]
51
52
53 class AlbumMerchantInline(admin.TabularInline):
54 model = AlbumMerchant
55
56
57 class AlbumMerchantAdmin(admin.ModelAdmin):
58 list_display = ['name', 'album']
59 list_filter = ['album']
60
61
62 class AlbumAdmin(admin.ModelAdmin):
63 save_on_top = True
64 inlines = [
65 AlbumTrackInline,
66 LabelReleaseInline,
67 AlbumMerchantInline,
68 ]
69
70
71 class MerchandiseAdmin(admin.ModelAdmin):
72 list_display = ['name', 'price', 'in_stock']
73 list_filter = ['in_stock']
74
75
76 admin.site.register(Gear, GearAdmin)
77 admin.site.register(Member, MemberAdmin)
78 admin.site.register(AlbumTrack, AlbumTrackAdmin)
79 admin.site.register(LabelRelease, LabelReleaseAdmin)
80 admin.site.register(RecordLabel, RecordLabelAdmin)
81 admin.site.register(AlbumMerchant, AlbumMerchantAdmin)
82 admin.site.register(Album, AlbumAdmin)
83 admin.site.register(Merchandise, MerchandiseAdmin)