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:
@@ -3,26 +3,9 @@ from django.db import models
|
||||
|
||||
class Address(models.Model):
|
||||
"""
|
||||
Модель адреса доставки для заказа цветочного магазина в Минске.
|
||||
Адрес принадлежит конкретному заказу доставки.
|
||||
Модель адреса доставки.
|
||||
Адрес может использоваться в разных заказах и для разных получателей.
|
||||
"""
|
||||
# Информация о получателе
|
||||
recipient_name = models.CharField(
|
||||
max_length=200,
|
||||
blank=True,
|
||||
null=True,
|
||||
verbose_name="Имя получателя",
|
||||
help_text="Имя человека, которому будет доставлен заказ"
|
||||
)
|
||||
|
||||
recipient_phone = models.CharField(
|
||||
max_length=20,
|
||||
blank=True,
|
||||
null=True,
|
||||
verbose_name="Телефон получателя",
|
||||
help_text="Контактный телефон получателя для уточнения адреса"
|
||||
)
|
||||
|
||||
street = models.CharField(
|
||||
max_length=255,
|
||||
blank=True,
|
||||
@@ -103,12 +86,7 @@ class Address(models.Model):
|
||||
if self.apartment_number:
|
||||
address_parts.append(f"кв/офис {self.apartment_number}")
|
||||
|
||||
address_line = ", ".join(address_parts) if address_parts else "Адрес не указан"
|
||||
|
||||
# Формируем строку с именем получателя
|
||||
if self.recipient_name:
|
||||
return f"{self.recipient_name} - {address_line}"
|
||||
return address_line
|
||||
return ", ".join(address_parts) if address_parts else "Адрес не указан"
|
||||
|
||||
@property
|
||||
def full_address(self):
|
||||
|
||||
Reference in New Issue
Block a user