feat(orders): add recipient management and enhance order forms
- Introduced Recipient model to manage order recipients separately from customers. - Updated Order model to link to Recipient, replacing recipient_name and recipient_phone fields. - Enhanced OrderForm to include recipient selection modes: customer, history, and new. - Added AJAX endpoint to fetch recipient history for customers. - Updated admin interface to manage recipients and display recipient information in order details. - Refactored address handling to accommodate new recipient logic. - Improved demo order creation to include random recipients.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from django.contrib import admin
|
||||
from django.utils.html import format_html
|
||||
from .models import Order, OrderItem, Transaction, PaymentMethod, Address, OrderStatus
|
||||
from .models import Order, OrderItem, Transaction, PaymentMethod, Address, OrderStatus, Recipient
|
||||
|
||||
|
||||
class TransactionInline(admin.TabularInline):
|
||||
@@ -61,7 +61,7 @@ class OrderAdmin(admin.ModelAdmin):
|
||||
'customer__name',
|
||||
'customer__phone',
|
||||
'customer__email',
|
||||
'delivery_address__recipient_name',
|
||||
'recipient__name',
|
||||
'delivery_address__street',
|
||||
]
|
||||
|
||||
@@ -240,8 +240,6 @@ class AddressAdmin(admin.ModelAdmin):
|
||||
Админ-панель для управления адресами доставки заказов.
|
||||
"""
|
||||
list_display = [
|
||||
'recipient_name',
|
||||
'recipient_phone',
|
||||
'full_address',
|
||||
'entrance',
|
||||
'floor',
|
||||
@@ -255,7 +253,6 @@ class AddressAdmin(admin.ModelAdmin):
|
||||
]
|
||||
|
||||
search_fields = [
|
||||
'recipient_name',
|
||||
'street',
|
||||
'building_number',
|
||||
]
|
||||
@@ -263,9 +260,6 @@ class AddressAdmin(admin.ModelAdmin):
|
||||
readonly_fields = ['created_at', 'updated_at']
|
||||
|
||||
fieldsets = (
|
||||
('Информация о получателе', {
|
||||
'fields': ('recipient_name', 'recipient_phone')
|
||||
}),
|
||||
('Адрес доставки', {
|
||||
'fields': ('street', 'building_number', 'apartment_number', 'entrance', 'floor')
|
||||
}),
|
||||
@@ -284,6 +278,39 @@ class AddressAdmin(admin.ModelAdmin):
|
||||
)
|
||||
|
||||
|
||||
@admin.register(Recipient)
|
||||
class RecipientAdmin(admin.ModelAdmin):
|
||||
"""
|
||||
Админ-панель для управления получателями заказов.
|
||||
"""
|
||||
list_display = [
|
||||
'name',
|
||||
'phone',
|
||||
'created_at',
|
||||
]
|
||||
|
||||
list_filter = [
|
||||
'created_at',
|
||||
]
|
||||
|
||||
search_fields = [
|
||||
'name',
|
||||
'phone',
|
||||
]
|
||||
|
||||
readonly_fields = ['created_at', 'updated_at']
|
||||
|
||||
fieldsets = (
|
||||
('Информация о получателе', {
|
||||
'fields': ('name', 'phone')
|
||||
}),
|
||||
('Даты', {
|
||||
'fields': ('created_at', 'updated_at'),
|
||||
'classes': ('collapse',)
|
||||
}),
|
||||
)
|
||||
|
||||
|
||||
@admin.register(OrderStatus)
|
||||
class OrderStatusAdmin(admin.ModelAdmin):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user