Configure shop app, admin sidebar, media routing, and Stripe dependencies
This commit is contained in:
commit
93d83a0d63
188 files changed
+9220
No files matched your search
@@ -0,0 +1,107 @@
|
||||
# Generated by Django 5.2.19 on 2026-11-22 18:26
|
||||
|
||||
import django.core.validators
|
||||
import django.db.models.deletion
|
||||
import uuid
|
||||
from decimal import Decimal
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Product',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('title', models.CharField(max_length=160)),
|
||||
('slug', models.SlugField(max_length=180, unique=True)),
|
||||
('kind', models.CharField(choices=[('physical', 'Physical Product'), ('digital', 'Digital Download'), ('subscription', 'Recurring Subscription')], default='physical', max_length=20)),
|
||||
('summary', models.CharField(blank=True, max_length=280)),
|
||||
('description', models.TextField(blank=True)),
|
||||
('image', models.ImageField(blank=True, upload_to='shop/products/')),
|
||||
('price_usd', models.DecimalField(decimal_places=2, max_digits=9, validators=[django.core.validators.MinValueValidator(Decimal('0.50'))])),
|
||||
('active', models.BooleanField(default=True)),
|
||||
('featured', models.BooleanField(default=False)),
|
||||
('position', models.PositiveIntegerField(default=0)),
|
||||
('stock', models.PositiveIntegerField(default=0, help_text='Ignored for digital and subscription items.')),
|
||||
('track_stock', models.BooleanField(default=True)),
|
||||
('shipping_usd', models.DecimalField(decimal_places=2, default=Decimal('0.00'), help_text='Flat shipping fee added once if order contains physical items.', max_digits=7)),
|
||||
('digital_file', models.FileField(blank=True, help_text='Private file unlocked after purchase.', upload_to='shop/private_digital/')),
|
||||
('billing_interval', models.CharField(choices=[('month', 'Monthly'), ('year', 'Yearly')], default='month', max_length=10)),
|
||||
('stripe_price_id', models.CharField(blank=True, help_text='Optional Stripe recurring Price ID (price_...). If blank, created dynamically.', max_length=120)),
|
||||
('paypal_plan_id', models.CharField(blank=True, help_text='Required for PayPal recurring subscriptions (P-...).', max_length=120)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
],
|
||||
options={
|
||||
'ordering': ['position', '-created_at'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Order',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('order_id', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
|
||||
('email', models.EmailField(max_length=254)),
|
||||
('full_name', models.CharField(blank=True, max_length=160)),
|
||||
('status', models.CharField(choices=[('pending', 'Pending Payment'), ('paid', 'Paid / Processing'), ('shipped', 'Shipped'), ('delivered', 'Delivered'), ('refunded', 'Refunded'), ('canceled', 'Canceled')], default='pending', max_length=20)),
|
||||
('gateway', models.CharField(choices=[('stripe', 'Stripe'), ('paypal', 'PayPal')], max_length=20)),
|
||||
('subtotal_usd', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=10)),
|
||||
('shipping_usd', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=8)),
|
||||
('total_usd', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=10)),
|
||||
('shipping_line1', models.CharField(blank=True, max_length=200)),
|
||||
('shipping_line2', models.CharField(blank=True, max_length=200)),
|
||||
('shipping_city', models.CharField(blank=True, max_length=120)),
|
||||
('shipping_state', models.CharField(blank=True, max_length=120)),
|
||||
('shipping_postal', models.CharField(blank=True, max_length=40)),
|
||||
('shipping_country', models.CharField(blank=True, max_length=2)),
|
||||
('tracking_number', models.CharField(blank=True, max_length=120)),
|
||||
('gateway_session_id', models.CharField(blank=True, db_index=True, max_length=200)),
|
||||
('gateway_payment_id', models.CharField(blank=True, max_length=200)),
|
||||
('paid_at', models.DateTimeField(blank=True, null=True)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='shop_orders', to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
options={
|
||||
'ordering': ['-created_at'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='OrderItem',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('title_snapshot', models.CharField(max_length=160)),
|
||||
('unit_price_usd', models.DecimalField(decimal_places=2, max_digits=9)),
|
||||
('quantity', models.PositiveIntegerField(default=1)),
|
||||
('order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='items', to='shop.order')),
|
||||
('product', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='shop.product')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Subscription',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('sub_id', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
|
||||
('email', models.EmailField(max_length=254)),
|
||||
('gateway', models.CharField(choices=[('stripe', 'Stripe'), ('paypal', 'PayPal')], max_length=20)),
|
||||
('gateway_sub_id', models.CharField(blank=True, db_index=True, max_length=200)),
|
||||
('gateway_customer_id', models.CharField(blank=True, max_length=200)),
|
||||
('status', models.CharField(choices=[('pending', 'Pending'), ('active', 'Active'), ('past_due', 'Past Due'), ('canceled', 'Canceled')], default='pending', max_length=20)),
|
||||
('current_period_end', models.DateTimeField(blank=True, null=True)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('product', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='shop.product')),
|
||||
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='shop_subscriptions', to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
options={
|
||||
'ordering': ['-created_at'],
|
||||
},
|
||||
),
|
||||
]
|
||||
Whitespace-only changes.
Reference in new issue
Block a user