Some checks failed
Build and Push to Docker Hub / build-test-push (push) Failing after 1m55s
212 lines
4.4 KiB
Python
212 lines
4.4 KiB
Python
"""
|
|
Dajngo admin panel models register
|
|
"""
|
|
|
|
from django.contrib import admin
|
|
|
|
from core.apps.eggs import models
|
|
from core.apps.eggs.models.notification import Notification
|
|
|
|
|
|
@admin.register(models.Courier)
|
|
class CourierAdmin(admin.ModelAdmin):
|
|
list_display = ["id", "user_id", "courier_name"]
|
|
|
|
def courier_name(self, obj):
|
|
return f"{obj.user_id.first_name} {obj.user_id.last_name}"
|
|
|
|
|
|
@admin.register(models.CourierProduct)
|
|
class CourierProductAdmin(admin.ModelAdmin):
|
|
list_display = [
|
|
"id",
|
|
"courier_id",
|
|
"group_id",
|
|
"count",
|
|
"return_eggs",
|
|
"created_at",
|
|
]
|
|
|
|
|
|
@admin.register(models.CourierHistory)
|
|
class CourierHistoryAdmin(admin.ModelAdmin):
|
|
list_display = [
|
|
"id",
|
|
"courier_id",
|
|
"group_id",
|
|
"get_eggs",
|
|
"return_eggs",
|
|
"broken_eggs",
|
|
"date",
|
|
"courier_product_id",
|
|
]
|
|
|
|
|
|
@admin.register(models.Group)
|
|
class GroupAdmin(admin.ModelAdmin):
|
|
list_display = [
|
|
"id",
|
|
"product_id",
|
|
"party_id",
|
|
"entry_price",
|
|
"unit_price",
|
|
"wholesale_price",
|
|
"quantity",
|
|
"broken_eggs",
|
|
]
|
|
|
|
|
|
@admin.register(models.Invoice)
|
|
class InvoiceAdmin(admin.ModelAdmin):
|
|
list_display = ["id", "name", "price", "party_id"]
|
|
|
|
|
|
@admin.register(models.Location)
|
|
class LocationAdmin(admin.ModelAdmin):
|
|
list_display = ["id", "long", "lat", "label"]
|
|
|
|
|
|
@admin.register(models.Market)
|
|
class MarketAdmin(admin.ModelAdmin):
|
|
list_display = [
|
|
"id",
|
|
"name",
|
|
"company_name",
|
|
"user_id",
|
|
"phone",
|
|
"debt_paid",
|
|
"debt_unpaid",
|
|
]
|
|
|
|
|
|
@admin.register(models.Order)
|
|
class OrderAdmin(admin.ModelAdmin):
|
|
list_display = [
|
|
"id",
|
|
"courier_id",
|
|
"market_id",
|
|
"data",
|
|
"status",
|
|
"price",
|
|
"price_paid",
|
|
"debt",
|
|
]
|
|
|
|
|
|
@admin.register(models.OrderItems)
|
|
class OrderItemsAdmin(admin.ModelAdmin):
|
|
list_display = [
|
|
"id",
|
|
"group_id",
|
|
"count",
|
|
"discount",
|
|
"courier_product_id",
|
|
"order_id",
|
|
"sale_type",
|
|
]
|
|
|
|
|
|
@admin.register(models.Party)
|
|
class PartAdmin(admin.ModelAdmin):
|
|
list_display = [
|
|
"id",
|
|
"user_id",
|
|
"count",
|
|
"sold_count",
|
|
"remaining_count",
|
|
"benefit",
|
|
"cost",
|
|
"total_cost",
|
|
]
|
|
|
|
|
|
@admin.register(models.Product)
|
|
class ProductAdmin(admin.ModelAdmin):
|
|
list_display = ["id", "name"]
|
|
|
|
|
|
@admin.register(models.Broken)
|
|
class BrokenAdmin(admin.ModelAdmin):
|
|
list_display = ["id", "group", "comment", "quantity", "user"]
|
|
|
|
def user(self, obj):
|
|
return f"{obj.user_id.first_name} {obj.user_id.last_name}"
|
|
|
|
|
|
@admin.register(models.Debt)
|
|
class DebtAdmin(admin.ModelAdmin):
|
|
list_display = ["id", "market", "debt_price"]
|
|
|
|
|
|
@admin.register(models.History)
|
|
class HistoryAdmin(admin.ModelAdmin):
|
|
list_display = [
|
|
"id",
|
|
"content_type",
|
|
"object_id",
|
|
"action",
|
|
"timestamp",
|
|
"created_by",
|
|
"created_who",
|
|
"reason",
|
|
"comment",
|
|
]
|
|
|
|
|
|
# @admin.register(models.AllHistory)
|
|
# class AllHistoryAdmin(admin.ModelAdmin):
|
|
# list_display = [
|
|
# "id",
|
|
# "content_type",
|
|
# "object_id",
|
|
# "action",
|
|
# "timestamp",
|
|
# "created_by",
|
|
# "created_who",
|
|
# "reason",
|
|
# ]
|
|
|
|
|
|
@admin.register(models.AdditionalCost)
|
|
class AdditionalCostAdmin(admin.ModelAdmin):
|
|
list_display = ["id", "user", "reason", "price", "created_at"]
|
|
readonly_fields = ["created_at"]
|
|
|
|
def user(self, obj):
|
|
return f"{obj.user.first_name} {obj.user.last_name}"
|
|
|
|
|
|
@admin.register(models.Sklad)
|
|
class SkladAdmin(admin.ModelAdmin):
|
|
list_display = ["id", "user_id"]
|
|
|
|
def user_id(self, obj):
|
|
return f"{obj.user_id.first_name} {obj.user_id.last_name}"
|
|
|
|
|
|
@admin.register(models.Monitoring)
|
|
class MonitoringAdmin(admin.ModelAdmin):
|
|
list_display = [
|
|
"id",
|
|
"content_type",
|
|
"object_id",
|
|
"action",
|
|
"timestamp",
|
|
"created_by",
|
|
"created_who",
|
|
"reason",
|
|
"comment",
|
|
"price",
|
|
]
|
|
|
|
|
|
@admin.register(Notification)
|
|
class NotificationAdmin(admin.ModelAdmin):
|
|
list_display = ("title", "body", "user", "is_read", "is_sending")
|
|
|
|
|
|
@admin.register(models.DailyCost)
|
|
class DailyCostAdmin(admin.ModelAdmin):
|
|
list_display = ["id", "first_cost", "second_cost", "third_cost", "created_at"]
|
|
readonly_fields = ["created_at"]
|