2011-09-20 18:16:49 +00:00
|
|
|
from django.contrib import admin
|
|
|
|
from django.contrib.contenttypes import generic
|
|
|
|
|
2011-10-13 21:34:56 +00:00
|
|
|
from .models import (Media, PhoneNumber, Episode, EpisodeExtra, Contact,
|
2011-09-20 18:16:49 +00:00
|
|
|
Category, EpisodePermanent, EpisodeMaxNum)
|
|
|
|
|
2011-10-13 21:34:56 +00:00
|
|
|
|
2011-09-20 18:16:49 +00:00
|
|
|
site = admin.AdminSite(name="admin")
|
|
|
|
|
2013-11-03 04:36:09 +00:00
|
|
|
|
2011-09-20 18:16:49 +00:00
|
|
|
class MediaInline(generic.GenericTabularInline):
|
|
|
|
model = Media
|
|
|
|
|
|
|
|
|
|
|
|
class EpisodeAdmin(admin.ModelAdmin):
|
|
|
|
inlines = [
|
|
|
|
MediaInline,
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
class MediaExtraInline(generic.GenericTabularInline):
|
|
|
|
model = Media
|
|
|
|
extra = 0
|
|
|
|
|
|
|
|
|
|
|
|
class MediaMaxNumInline(generic.GenericTabularInline):
|
|
|
|
model = Media
|
|
|
|
extra = 5
|
|
|
|
max_num = 2
|
|
|
|
|
|
|
|
|
|
|
|
class PhoneNumberInline(generic.GenericTabularInline):
|
|
|
|
model = PhoneNumber
|
|
|
|
|
|
|
|
|
|
|
|
class MediaPermanentInline(generic.GenericTabularInline):
|
|
|
|
model = Media
|
|
|
|
can_delete = False
|
|
|
|
|
|
|
|
|
|
|
|
site.register(Episode, EpisodeAdmin)
|
|
|
|
site.register(EpisodeExtra, inlines=[MediaExtraInline])
|
|
|
|
site.register(EpisodeMaxNum, inlines=[MediaMaxNumInline])
|
|
|
|
site.register(Contact, inlines=[PhoneNumberInline])
|
|
|
|
site.register(Category)
|
|
|
|
site.register(EpisodePermanent, inlines=[MediaPermanentInline])
|