Configure PayPal integration and cart checkout error display

This commit is contained in:
Zach committed 2026-12-01 04:20:38 +00:00
1 parent 62065828e1
commit cf07fc5d9b
98 files changed
+1430 -281

No files matched your search

+93 -7
View File
@@ -120,6 +120,8 @@ class PageSharePreview(models.Model):
class SiteSettings(models.Model):
countdown_map_position = models.CharField(max_length=6, default='below',
choices=[('above', 'Above countdown content'), ('below', 'Below countdown content')])
name = models.CharField(max_length=100, default='SLUMP X LAND', editable=False)
site_palette = models.JSONField(default=dict, blank=True)
hidden_menu = models.JSONField(default=list, blank=True)
@@ -228,7 +230,7 @@ class Chapter(models.Model):
title = models.CharField(max_length=180)
cover = art_field(blank=True)
price_usd = models.DecimalField('Chapter price (USD)', max_digits=7, decimal_places=2, null=True, blank=True,
validators=[MinValueValidator(0)], help_text='Leave blank or set to zero for a free chapter.')
validators=[MinValueValidator(0)], help_text='Set at least $0.50 for a Stripe chapter purchase. Leave blank if this chapter is only available to members.')
def clean(self):
super().clean()
@@ -590,7 +592,7 @@ class StreamComment(models.Model):
class FanMembership(models.Model):
user = models.OneToOneField('auth.User', on_delete=models.CASCADE, related_name='slx_membership')
subscriber_until = models.DateTimeField('Subscription active through', null=True, blank=True)
member_tier = models.PositiveSmallIntegerField('Content tier', choices=[(1, 'Early Access'), (2, 'Studio Vault')], default=1)
member_tier = models.PositiveSmallIntegerField('Content tier', choices=[(1, 'Early Access'), (2, 'Studio Vault'), (3, 'Collector’s Circle')], default=1)
sol_seat = models.BooleanField('Assign Sol Seat', default=False)
class Meta:
@@ -604,7 +606,7 @@ class MemberPost(models.Model):
title = models.CharField(max_length=160)
body = models.TextField(blank=True)
kind = models.CharField(max_length=12, choices=[('note','Creator note'),('early','Early chapter'),('draft','Draft pages')], default='note')
required_tier = models.PositiveSmallIntegerField(choices=[(1,'Early Access'),(2,'Studio Vault')],default=1)
required_tier = models.PositiveSmallIntegerField(choices=[(1,'Early Access'),(2,'Studio Vault'),(3,'Collector’s Circle')],default=1)
published = models.BooleanField(default=False)
publish_at = models.DateTimeField(default=timezone.now)
@@ -645,14 +647,27 @@ class TrafficDaily(models.Model):
target_id = models.PositiveBigIntegerField(default=0)
route = models.CharField(max_length=64)
country = models.CharField(max_length=2, blank=True, default='')
region = models.CharField(max_length=120, blank=True, default='')
city = models.CharField(max_length=120, blank=True, default='')
source = models.CharField(max_length=255, blank=True, default='')
views = models.PositiveBigIntegerField(default=1)
class Meta:
constraints = [models.UniqueConstraint(fields=['day', 'kind', 'target_id', 'route', 'country', 'source'],
name='slx_traffic_daily_key')]
indexes = [models.Index(fields=['kind', 'target_id'], name='slx_traffic_item_idx')]
constraints = [
models.UniqueConstraint(
fields=[
'day', 'kind', 'target_id', 'route',
'country', 'region', 'city', 'source'
],
name='slx_traffic_daily_key'
)
]
indexes = [
models.Index(
fields=['kind', 'target_id'],
name='slx_traffic_item_idx'
)
]
class AIChapterReview(models.Model):
chapter = models.OneToOneField(Chapter, on_delete=models.CASCADE, related_name='ai_editorial_review')
@@ -730,3 +745,74 @@ class NewsletterDelivery(models.Model):
class Meta:
constraints = [models.UniqueConstraint(fields=['campaign', 'subscriber'], name='slx_unique_newsletter_delivery')]
class ManagedPage(models.Model):
title = models.CharField(max_length=160)
slug = models.SlugField(unique=True)
body = models.TextField(blank=True)
link = models.CharField(max_length=240, blank=True, help_text='Optional local destination, such as /shop/. Leave blank to publish the page body.')
map_slot = models.CharField(max_length=50, blank=True, editable=False)
menu_key = models.CharField(max_length=32, blank=True, help_text='Optional existing menu key to replace, such as read, blog, or shop.')
published = models.BooleanField(default=False)
show_in_menu = models.BooleanField(default=False)
homepage = models.BooleanField(default=False)
class Meta:
constraints = [models.UniqueConstraint(fields=['homepage'], condition=models.Q(homepage=True), name='slx_single_managed_home')]
def clean(self):
from urllib.parse import urlsplit
super().clean()
if self.link:
try:
parts = urlsplit(self.link)
except ValueError as exc:
raise ValidationError({'link': 'Enter a valid local path.'}) from exc
if not self.link.startswith('/') or self.link.startswith('//') or parts.netloc or (parts.path == '/' or parts.path.startswith('/pages/')) or '\\' in self.link or any(ord(c)<32 for c in self.link):
raise ValidationError({'link': 'Enter a local path other than the homepage, such as /shop/.'})
if self.homepage and not self.published:
raise ValidationError({'homepage': 'Publish this page before setting it as the homepage.'})
def get_absolute_url(self):
from django.urls import reverse
return reverse('managed-page', args=[self.slug])
def __str__(self):
return self.title
class MapLocation(models.Model):
title = models.CharField(max_length=80)
key = models.SlugField(max_length=50, unique=True)
path = models.CharField(max_length=240, blank=True, help_text='Optional override, e.g. /chapters/9/. Leave blank to follow the selected page.')
page = models.ForeignKey(ManagedPage, null=True, blank=True, on_delete=models.SET_NULL)
fallback_path = models.CharField(max_length=240, blank=True, editable=False)
x = models.DecimalField(max_digits=8, decimal_places=5, validators=[MinValueValidator(0), MaxValueValidator(100)])
y = models.DecimalField(max_digits=8, decimal_places=5, validators=[MinValueValidator(0), MaxValueValidator(100)])
visible = models.BooleanField(default=True)
position = models.PositiveIntegerField(default=0)
class Meta:
ordering = ['position', 'pk']
def clean(self):
super().clean()
if self.path and (not self.path.startswith('/') or self.path.startswith('//') or
'\\' in self.path or any(c.isspace() or ord(c) < 32 for c in self.path)):
raise ValidationError({'path': 'Enter an internal path starting with one slash.'})
if self.visible and not (self.path or self.page_id or self.fallback_path):
raise ValidationError({'path': 'Choose a page or enter a path.'})
def destination(self):
return self.path or (self.page.get_absolute_url() if self.page_id and self.page.published else self.fallback_path)
def __str__(self):
return self.title
class CollectorProfile(models.Model):
user = models.OneToOneField('auth.User', on_delete=models.CASCADE)
display_name = models.CharField(max_length=80, blank=True)
photo = art_field(blank=True)
public = models.BooleanField(default=False)