Files
Example-TCG-Site/users/models.py
Ryan Westfall 9040021d1b MASSIVE UPDATE:
bounty board feature

buyers to see bounty boards

seller profile page (like have theme chooser)

Have the game and set name be filters.

Add cards to vault manually

update card inventory add to have the autocomplete for the card  -

store analytics, clicks, views, link to store (url/QR code)

bulk item inventory creation --

Make the banner feature flag driven so I can have a beta site setup like the primary site

don't use primary key values in urls - update to use uuid4 values

site analytics. tianji is being sent

item potent on the mtg and lorcana populate scripts

Card item images for specific listings

check that when you buy a card it is in the vault

Buys should be able to search on store inventories

More pie charts for the seller!

post bounty board is slow to load

seller reviews/ratings - show a historgram - need a way for someone to rate

Report a seller feature for buyer to report

Make sure the stlying is consistent based on the theme choosen

smart minimum order quantity and shipping amounts (defined by the store itself)

put virtual packs behind a feature flag like bounty board

proxy service feature flag

Terms of Service

new description for TCGKof

store SSN, ITIN, and EIN

optomize for SEO
2026-01-23 12:28:20 -06:00

84 lines
3.2 KiB
Python

from django.contrib.auth.models import AbstractUser
from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver
class User(AbstractUser):
pass
class Profile(models.Model):
THEME_CHOICES = (
('light', 'Light'),
('dark', 'Dark'),
('compact', 'Compact'),
('expressive', 'Expressive'),
('technical', 'Technical'),
)
user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='profile')
is_pro = models.BooleanField(default=False)
is_seller = models.BooleanField(default=False)
theme_preference = models.CharField(max_length=10, choices=THEME_CHOICES, default='dark')
# Keeping this simple text field for legacy/simple addressing, whilst adding robust Address model below
shipping_address = models.TextField(blank=True)
stripe_customer_id = models.CharField(max_length=100, blank=True, null=True)
def __str__(self):
return self.user.username
@receiver(post_save, sender=User)
def create_user_profile(sender, instance, created, **kwargs):
if created:
Profile.objects.create(user=instance)
@receiver(post_save, sender=User)
def save_user_profile(sender, instance, **kwargs):
instance.profile.save()
class Address(models.Model):
ADDRESS_TYPE_CHOICES = (
('shipping', 'Shipping'),
('billing', 'Billing'),
)
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='addresses')
name = models.CharField(max_length=100)
street = models.CharField(max_length=200)
city = models.CharField(max_length=100)
state = models.CharField(max_length=100)
zip_code = models.CharField(max_length=20)
address_type = models.CharField(max_length=20, choices=ADDRESS_TYPE_CHOICES, default='shipping')
is_default = models.BooleanField(default=False)
def __str__(self):
return f"{self.name} - {self.street}"
class PaymentMethod(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='payment_methods')
# For now, we'll store mock data. In a real app complexity is higher (PCI compliance etc)
brand = models.CharField(max_length=50) # Visa, Mastercard
last4 = models.CharField(max_length=4)
exp_month = models.PositiveIntegerField()
exp_year = models.PositiveIntegerField()
is_default = models.BooleanField(default=False)
def __str__(self):
return f"{self.brand} ending in {self.last4}"
class Buyer(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='buyer_profile')
created_at = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.user.username
@receiver(post_save, sender=User)
def create_buyer_profile(sender, instance, created, **kwargs):
# We only auto-create Buyer if NOT a seller?
# Or do we create it manually in views?
# The requirement says "/user/register creates a buy account and /sell/register creates a seller account"
# So we probably shouldn't auto-create blindly for EVERY user if we want them distinct.
# However, easy way is to create it manually in the view.
# I will NOT add a signal here to avoid auto-creation when we might want a pure Seller.
pass