Template
Add shopper accounts, reviews, tracking, and seed_demo (#9)
Closes #9. Shop-gated buyer accounts, purchase reviews, Stripe customer ids, shipment tracking, slim public contact form, and a template-neutral seed_demo command.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
from accounts.models import CustomerProfile
|
||||
|
||||
|
||||
def get_customer_profile(user) -> CustomerProfile:
|
||||
profile, _created = CustomerProfile.objects.get_or_create(user=user)
|
||||
return profile
|
||||
|
||||
|
||||
def claim_orders_for_user(user) -> int:
|
||||
"""Attach guest orders that used this email so history/reviews work after signup."""
|
||||
from django.apps import apps
|
||||
|
||||
if not apps.is_installed("shop"):
|
||||
return 0
|
||||
from shop.models import Order
|
||||
|
||||
email = (user.email or user.username or "").strip()
|
||||
if not email:
|
||||
return 0
|
||||
return Order.objects.filter(user__isnull=True, email__iexact=email).update(
|
||||
user=user
|
||||
)
|
||||
Reference in New Issue
Block a user