cmsmanage/rentals/admin.py

30 lines
660 B
Python

from django.contrib import admin
from .models import LockerBank, LockerRental, LockerUnit
class LockerUnitInline(admin.TabularInline):
model = LockerUnit
extra = 0
@admin.register(LockerBank)
class LockerBankAdmin(admin.ModelAdmin):
inlines = [LockerUnitInline]
prepopulated_fields = {"slug": ("name",)}
class LockerRentalInline(admin.TabularInline):
model = LockerRental
extra = 0
@admin.register(LockerUnit)
class LockerUnitAdmin(admin.ModelAdmin):
inlines = [LockerRentalInline]
@admin.register(LockerRental)
class LockerRentalAdmin(admin.ModelAdmin):
search_fields = ["user__username", "locker_unit__bank__name"]