Added arbitrary files and links to boxes
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from django.contrib import admin
|
||||
from django_mptt_admin.admin import DjangoMpttAdmin
|
||||
|
||||
from .models import Box, BoxType, Thing, ThingType
|
||||
from .models import Box, BoxType, Thing, ThingFile, ThingLink, ThingType
|
||||
|
||||
|
||||
@admin.register(BoxType)
|
||||
@@ -35,3 +35,32 @@ class ThingAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'thing_type', 'box')
|
||||
list_filter = ('thing_type', 'box')
|
||||
search_fields = ('name', 'description')
|
||||
|
||||
|
||||
class ThingFileInline(admin.TabularInline):
|
||||
"""Inline admin for Thing files."""
|
||||
|
||||
model = ThingFile
|
||||
extra = 1
|
||||
fields = ('title', 'file')
|
||||
|
||||
|
||||
class ThingLinkInline(admin.TabularInline):
|
||||
"""Inline admin for Thing links."""
|
||||
|
||||
model = ThingLink
|
||||
extra = 1
|
||||
fields = ('title', 'url')
|
||||
|
||||
|
||||
class ThingAdminWithFiles(admin.ModelAdmin):
|
||||
"""Admin configuration for Thing model with files and links."""
|
||||
|
||||
list_display = ('name', 'thing_type', 'box')
|
||||
list_filter = ('thing_type', 'box')
|
||||
search_fields = ('name', 'description')
|
||||
inlines = [ThingFileInline, ThingLinkInline]
|
||||
|
||||
|
||||
admin.site.unregister(Thing)
|
||||
admin.register(Thing, ThingAdminWithFiles)
|
||||
|
||||
Reference in New Issue
Block a user