75 lines
1.8 KiB
Python
75 lines
1.8 KiB
Python
from django.contrib import admin
|
|
from django_mptt_admin.admin import DjangoMpttAdmin
|
|
|
|
from .models import Box, BoxType, Thing, ThingFile, ThingLink, ThingType
|
|
|
|
|
|
@admin.register(BoxType)
|
|
class BoxTypeAdmin(admin.ModelAdmin):
|
|
"""Admin configuration for BoxType model."""
|
|
|
|
list_display = ('name', 'width', 'height', 'length')
|
|
search_fields = ('name',)
|
|
|
|
|
|
@admin.register(Box)
|
|
class BoxAdmin(admin.ModelAdmin):
|
|
"""Admin configuration for Box model."""
|
|
|
|
list_display = ('id', 'box_type')
|
|
list_filter = ('box_type',)
|
|
search_fields = ('id',)
|
|
|
|
|
|
@admin.register(ThingType)
|
|
class ThingTypeAdmin(DjangoMpttAdmin):
|
|
"""Admin configuration for ThingType model."""
|
|
|
|
search_fields = ('name',)
|
|
|
|
|
|
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 ThingAdmin(admin.ModelAdmin):
|
|
"""Admin configuration for Thing model."""
|
|
|
|
list_display = ('name', 'thing_type', 'box')
|
|
list_filter = ('thing_type', 'box')
|
|
search_fields = ('name', 'description')
|
|
inlines = [ThingFileInline, ThingLinkInline]
|
|
|
|
|
|
admin.site.register(Thing, ThingAdmin)
|
|
|
|
|
|
@admin.register(ThingFile)
|
|
class ThingFileAdmin(admin.ModelAdmin):
|
|
"""Admin configuration for ThingFile model."""
|
|
|
|
list_display = ('thing', 'title', 'uploaded_at')
|
|
list_filter = ('thing',)
|
|
search_fields = ('title',)
|
|
|
|
|
|
@admin.register(ThingLink)
|
|
class ThingLinkAdmin(admin.ModelAdmin):
|
|
"""Admin configuration for ThingLink model."""
|
|
|
|
list_display = ('thing', 'title', 'url', 'uploaded_at')
|
|
list_filter = ('thing',)
|
|
search_fields = ('title', 'url')
|