Spaces:
Running
Running
Download api/models/orders.py from Dayozoe/harvestconnect-api: direct link, hf CLI and curl.
- Browser
- Download file 1.14 kB
-
https://huggingface.co/spaces/Dayozoe/harvestconnect-api/resolve/main/api/models/orders.py
- Command line
-
hf download hf://spaces/Dayozoe/harvestconnect-api/api/models/orders.py
-
curl -L -o orders.py https://huggingface.co/spaces/Dayozoe/harvestconnect-api/resolve/main/api/models/orders.py
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'] | |