2011-10-14 05:34:56 +08:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
from django.contrib import admin
|
|
|
|
from django.contrib.contenttypes import generic
|
|
|
|
|
2011-10-14 05:34:56 +08:00
|
|
|
from .models import (Media, PhoneNumber, Episode, EpisodeExtra, Contact,
|
2011-09-21 02:16:49 +08:00
|
|
|
Category, EpisodePermanent, EpisodeMaxNum)
|
|
|
|
|
2011-10-14 05:34:56 +08:00
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
site = admin.AdminSite(name="admin")
|
|
|
|
|
|
|
|
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])
|