Django 6 + DRF resource server against the Gooyal accounts OAuth2 service, matching the Winsoo ecosystem's conventions. Covers locations, stores, catalog, cart, checkout/orders (with the multi-store-cart split and the status stepper), reviews, and notifications, plus a demo-data seed command. Payment integration (wallet debits, online gateway, seller payouts) is intentionally left out here — see feature/payment. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
28 lines
1.1 KiB
Python
28 lines
1.1 KiB
Python
from django.conf import settings
|
|
from django.core.validators import MaxValueValidator, MinValueValidator
|
|
from django.db import models
|
|
|
|
from apps.catalog.models import Product
|
|
from apps.orders.models import Order
|
|
from apps.stores.models import Store
|
|
from utils.models import BaseModel
|
|
|
|
|
|
class Review(BaseModel):
|
|
order = models.OneToOneField(Order, on_delete=models.CASCADE, related_name='review')
|
|
customer = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='reviews')
|
|
store = models.ForeignKey(Store, on_delete=models.CASCADE, related_name='reviews')
|
|
product = models.ForeignKey(
|
|
Product, on_delete=models.SET_NULL, null=True, blank=True, related_name='reviews',
|
|
)
|
|
rating = models.PositiveSmallIntegerField(validators=[MinValueValidator(1), MaxValueValidator(5)])
|
|
comment = models.TextField(blank=True)
|
|
seller_reply = models.TextField(blank=True)
|
|
|
|
class Meta:
|
|
ordering = ['-created_at']
|
|
verbose_name = 'نظر'
|
|
verbose_name_plural = 'نظرات'
|
|
|
|
def __str__(self):
|
|
return f'{self.store.name} - {self.rating}/5'
|