Restore and lock in shop app, admin sidebar, media routing, and Stripe

This commit is contained in:
Zach committed 2026-11-24 18:31:31 +00:00
1 parent 93d83a0d63
commit 3cfea85499
15 files changed
+486 -73

No files matched your search

+29 -3
View File
@@ -476,6 +476,9 @@ class BookListing(models.Model):
cover = art_field(verbose_name='Product image', blank=True)
paypal_url = models.URLField('PayPal Payment Link', blank=True, validators=[validate_book_checkout],
help_text='Use for a product with no variants. When variants exist, each uses its own link.')
price_usd = models.DecimalField('Stripe price (USD)', max_digits=8, decimal_places=2, null=True, blank=True,
validators=[MinValueValidator(Decimal('0.50'))], help_text='Charged by Stripe when this product has no variants.')
ships = models.BooleanField('Ship this product', default=True, help_text='Collect a shipping address at Stripe Checkout.')
visible = models.BooleanField(default=False)
class Meta:
@@ -507,10 +510,10 @@ class ProductVariant(models.Model):
option = models.CharField('Edition / size / color', max_length=90, blank=True,
help_text='Optional. For example: XL / Black, Signed copy, or Blue pressing.')
art = art_field(verbose_name='Variant image', blank=True, help_text='Leave blank to use the main product image.')
price_usd = models.DecimalField('Display price (USD)', max_digits=8, decimal_places=2, null=True, blank=True,
price_usd = models.DecimalField('Price (USD)', max_digits=8, decimal_places=2, null=True, blank=True,
validators=[MinValueValidator(Decimal('0.01'))],
help_text='Optional. Enter the same price you set in PayPal; this field does not change the checkout price.')
paypal_url = models.URLField('PayPal Payment Link', validators=[validate_book_checkout])
help_text='Charged by Stripe. If using a PayPal link, set the PayPal price separately.')
paypal_url = models.URLField('PayPal Payment Link', blank=True, validators=[validate_book_checkout])
visible = models.BooleanField(default=True)
order = models.PositiveSmallIntegerField('Display order', default=0, help_text='Lower numbers appear first.')
@@ -522,6 +525,29 @@ class ProductVariant(models.Model):
return f'{label} · {self.option}' if self.option else label
class ShopOrder(models.Model):
class Status(models.TextChoices):
OPEN = 'open', 'Awaiting payment'
PAID = 'paid', 'Paid'
EXPIRED = 'expired', 'Expired'
FAILED = 'failed', 'Checkout unavailable'
reference = models.UUIDField(default=uuid4, unique=True, editable=False)
item = models.CharField(max_length=320)
amount_cents = models.PositiveIntegerField()
livemode = models.BooleanField()
status = models.CharField(max_length=10, choices=Status, default=Status.OPEN, db_index=True)
stripe_session = models.CharField(max_length=255, unique=True, null=True, blank=True)
payment_intent = models.CharField(max_length=255, blank=True)
email = models.EmailField(blank=True)
created_at = models.DateTimeField(auto_now_add=True)
paid_at = models.DateTimeField(null=True, blank=True)
fulfilled = models.BooleanField(default=False)
class Meta:
ordering = ['-created_at']
class ChapterPurchase(models.Model):
user = models.ForeignKey('auth.User', on_delete=models.PROTECT)
chapter = models.ForeignKey(Chapter, on_delete=models.PROTECT, related_name='purchases')