first commit
This commit is contained in:
85
core/apps/management/admin.py
Normal file
85
core/apps/management/admin.py
Normal file
@@ -0,0 +1,85 @@
|
||||
from django.contrib import admin
|
||||
from .models import (
|
||||
Region, District, Warehouse, Device,
|
||||
ToyMovement, Income, Expense
|
||||
)
|
||||
from core.apps.accounts.models import User # for ForeignKey references
|
||||
|
||||
|
||||
# -------------------------
|
||||
# Region Admin
|
||||
# -------------------------
|
||||
@admin.register(Region)
|
||||
class RegionAdmin(admin.ModelAdmin):
|
||||
list_display = ("name",)
|
||||
search_fields = ("name",)
|
||||
|
||||
|
||||
# -------------------------
|
||||
# District Admin
|
||||
# -------------------------
|
||||
@admin.register(District)
|
||||
class DistrictAdmin(admin.ModelAdmin):
|
||||
list_display = ("name", "region")
|
||||
list_filter = ("region",)
|
||||
search_fields = ("name", "region__name")
|
||||
|
||||
|
||||
# -------------------------
|
||||
# Warehouse Admin
|
||||
# -------------------------
|
||||
@admin.register(Warehouse)
|
||||
class WarehouseAdmin(admin.ModelAdmin):
|
||||
list_display = ("name", "region", "toys_count", "created_at")
|
||||
list_filter = ("region",)
|
||||
search_fields = ("name", "region__name")
|
||||
readonly_fields = ("created_at",)
|
||||
|
||||
|
||||
# -------------------------
|
||||
# Device Admin
|
||||
# -------------------------
|
||||
@admin.register(Device)
|
||||
class DeviceAdmin(admin.ModelAdmin):
|
||||
list_display = ("address", "district", "created_at")
|
||||
list_filter = ("district",)
|
||||
search_fields = ("name", "district__name",)
|
||||
readonly_fields = ("created_at",)
|
||||
|
||||
|
||||
# -------------------------
|
||||
# ToyMovement Admin
|
||||
# -------------------------
|
||||
@admin.register(ToyMovement)
|
||||
class ToyMovementAdmin(admin.ModelAdmin):
|
||||
list_display = (
|
||||
"movement_type", "from_warehouse", "to_warehouse",
|
||||
"device", "quantity", "created_by", "created_at"
|
||||
)
|
||||
list_filter = ("movement_type", "from_warehouse", "to_warehouse")
|
||||
search_fields = ("device__name", "created_by__phone")
|
||||
autocomplete_fields = ["device", "created_by", "from_warehouse", "to_warehouse"]
|
||||
readonly_fields = ("created_at",)
|
||||
|
||||
|
||||
# -------------------------
|
||||
# Income Admin
|
||||
# -------------------------
|
||||
@admin.register(Income)
|
||||
class IncomeAdmin(admin.ModelAdmin):
|
||||
list_display = ("device", "amount", "created_by", "created_at")
|
||||
list_filter = ("device",)
|
||||
search_fields = ("device__name", "created_by__phone")
|
||||
autocomplete_fields = ["device", "created_by",]
|
||||
readonly_fields = ("created_at",)
|
||||
|
||||
# -------------------------
|
||||
# Expense Admin
|
||||
# -------------------------
|
||||
@admin.register(Expense)
|
||||
class ExpenseAdmin(admin.ModelAdmin):
|
||||
list_display = ("amount", "expense_type", "created_by", "confirmed_by", "is_confirmed", "created_at")
|
||||
list_filter = ("expense_type", "is_confirmed")
|
||||
search_fields = ("expense_type__name", "created_by__phone", "confirmed_by__phone")
|
||||
autocomplete_fields = ["created_by", "confirmed_by"]
|
||||
readonly_fields = ("created_at",)
|
||||
Reference in New Issue
Block a user