Files
octopus/myproject/orders/models/recipient.py
Andrey Smakotin 6669d47cdf 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.
2025-12-23 00:08:41 +03:00

42 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from django.db import models
class Recipient(models.Model):
"""
Модель получателя заказа.
Один получатель может получать доставки по разным адресам.
"""
name = models.CharField(
max_length=200,
verbose_name="Имя получателя",
help_text="ФИО или название организации получателя"
)
phone = models.CharField(
max_length=20,
verbose_name="Телефон получателя",
help_text="Контактный телефон для связи с получателем"
)
# Временные метки
created_at = models.DateTimeField(auto_now_add=True, verbose_name="Дата создания")
updated_at = models.DateTimeField(auto_now=True, verbose_name="Дата обновления")
class Meta:
verbose_name = "Получатель"
verbose_name_plural = "Получатели"
indexes = [
models.Index(fields=['phone']),
models.Index(fields=['name']),
models.Index(fields=['created_at']),
]
ordering = ['-created_at']
def __str__(self):
return f"{self.name} ({self.phone})"
@property
def display_name(self):
"""Форматированное имя для отображения"""
return f"{self.name} - {self.phone}"