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>
8 lines
324 B
Python
8 lines
324 B
Python
from django.db.models import Avg, Count
|
|
|
|
|
|
def refresh_store_rating(store):
|
|
aggregate = store.reviews.aggregate(avg=Avg('rating'), count=Count('uuid'))
|
|
store.rating_avg = aggregate['avg'] or 0
|
|
store.rating_count = aggregate['count'] or 0
|
|
store.save(update_fields=['rating_avg', 'rating_count', 'updated_at'])
|