cmsmanage/rentals/admin.py

33 lines
853 B
Python

from django.contrib import admin
from .models import LockerBank, LockerInfo, LockerUnit
class LockerInfoInline(admin.TabularInline):
model = LockerInfo
extra = 0
class LockerUnitInline(admin.TabularInline):
model = LockerUnit
extra = 0
@admin.register(LockerBank)
class LockerBankAdmin(admin.ModelAdmin):
inlines = [LockerUnitInline]
prepopulated_fields = {"slug": ("name",)}
@admin.register(LockerUnit)
class LockerUnitAdmin(admin.ModelAdmin):
inlines = [LockerInfoInline]
@admin.register(LockerInfo)
class LockerInfoAdmin(admin.ModelAdmin):
search_fields = ["renter__username", "locker_unit__bank__name"]
list_filter = ["locker_unit__bank", "locker_unit", "renter"]
list_display = ["locker_unit", "address", "blind_code", "bitting_code", "renter"]
list_display_links = ["locker_unit", "address"]