Dayozoe's picture
feat: deploy HarvestConnect Django API with crash-proof persistent volume
a6be783 verified
Raw History Blame Contribute Delete
1.14 kB
import uuid
from django.db import models
from django.contrib.auth.models import User
class Order(models.Model):
"""Orders placed by customers"""
STATUS_CHOICES = [
('pending', 'Pending'),
('confirmed', 'Confirmed'),
('shipped', 'Shipped'),
('delivered', 'Delivered'),
('cancelled', 'Cancelled'),
]
order_id = models.CharField(max_length=50, unique=True, default=uuid.uuid4, editable=False)
buyer = models.ForeignKey(User, on_delete=models.PROTECT, related_name='orders')
products = models.JSONField() # Store product details at time of order
total_amount = models.DecimalField(max_digits=10, decimal_places=2)
status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='pending')
shipping_address = models.TextField()
payment_method = models.CharField(max_length=50, blank=True)
notes = models.TextField(blank=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
def __str__(self):
return f"Order {self.order_id}"
class Meta:
ordering = ['-created_at']