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
This commit is contained in:
2026-01-23 12:28:20 -06:00
parent c43603bfb5
commit 9040021d1b
80 changed files with 6938 additions and 592 deletions

View File

@@ -1,12 +1,16 @@
import re
from .models import Card, CardListing, Order, OrderItem, VaultItem
from django.db.models import Min
import base64
from cryptography.fernet import Fernet
from django.conf import settings
from decimal import Decimal
def add_to_vault(user, card, quantity=1):
def add_to_vault(buyer, card, quantity=1):
"""
Adds a card to the user's vault.
Adds a card to the buyer's vault.
"""
vault_item, created = VaultItem.objects.get_or_create(user=user, card=card)
vault_item, created = VaultItem.objects.get_or_create(buyer=buyer, card=card)
if not created:
vault_item.quantity += quantity
else:
@@ -96,10 +100,10 @@ def get_user_collection(user):
Returns a dict {card_name: quantity} of cards in user's vault.
"""
owned = {}
if not user.is_authenticated:
if not user.is_authenticated or not hasattr(user, 'buyer_profile'):
return owned
vault_items = VaultItem.objects.filter(user=user).select_related('card')
vault_items = VaultItem.objects.filter(buyer=user.buyer_profile).select_related('card')
for item in vault_items:
owned[item.card.name] = item.quantity
@@ -130,4 +134,54 @@ def filter_deck_by_collection(parsed_cards, owned_cards):
if remaining > 0:
filtered.append({'name': name, 'quantity': remaining})
return filtered
class Encryptor:
"""
Utility for encrypting and decrypting sensitive data using Fernet.
Derives a key from settings.SECRET_KEY.
"""
_cipher = None
@classmethod
def get_cipher(cls):
if cls._cipher is None:
# Derive a 32-byte key from SECRET_KEY
# Ensure key is url-safe base64-encoded 32-byte key
# We use hashlib to ensure we get a valid 32-byte key for Fernet,
# regardless of SECRET_KEY length.
import hashlib
key_hash = hashlib.sha256(settings.SECRET_KEY.encode('utf-8')).digest()
key_b64 = base64.urlsafe_b64encode(key_hash)
cls._cipher = Fernet(key_b64)
return cls._cipher
@classmethod
def encrypt(cls, plaintext):
if not plaintext:
return None
if isinstance(plaintext, str):
plaintext = plaintext.encode('utf-8')
return cls.get_cipher().encrypt(plaintext)
@classmethod
def decrypt(cls, ciphertext):
if not ciphertext:
return None
if isinstance(ciphertext, memoryview):
ciphertext = bytes(ciphertext)
try:
return cls.get_cipher().decrypt(ciphertext).decode('utf-8')
except Exception:
return None
def calculate_platform_fee(total_amount):
"""
Calculates platform fee: 5% + $0.70, capped at $25.
"""
if not total_amount:
return Decimal('0.00')
fee = (total_amount * Decimal('0.05')) + Decimal('0.70')
return min(fee, Decimal('25.00'))