Django 6 + DRF resource server against the Gooyal accounts OAuth2 service, matching the Winsoo ecosystem's conventions. Covers locations, stores, catalog, cart, checkout/orders (with the multi-store-cart split and the status stepper), reviews, and notifications, plus a demo-data seed command. Payment integration (wallet debits, online gateway, seller payouts) is intentionally left out here — see feature/payment. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
107 lines
6.6 KiB
Python
107 lines
6.6 KiB
Python
# Generated by Django 6.0.2 on 2026-08-09 10:29
|
||
|
||
import django.contrib.gis.db.models.fields
|
||
import django.core.validators
|
||
import django.db.models.deletion
|
||
import uuid
|
||
from django.conf import settings
|
||
from django.db import migrations, models
|
||
|
||
|
||
class Migration(migrations.Migration):
|
||
|
||
initial = True
|
||
|
||
dependencies = [
|
||
('locations', '0001_initial'),
|
||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||
]
|
||
|
||
operations = [
|
||
migrations.CreateModel(
|
||
name='StoreCategory',
|
||
fields=[
|
||
('uuid', models.UUIDField(db_index=True, default=uuid.uuid4, primary_key=True, serialize=False, unique=True)),
|
||
('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
|
||
('updated_at', models.DateTimeField(auto_now=True, db_index=True)),
|
||
('name', models.CharField(max_length=100, unique=True)),
|
||
('icon', models.ImageField(blank=True, null=True, upload_to='store_categories/')),
|
||
('order', models.PositiveSmallIntegerField(default=0)),
|
||
],
|
||
options={
|
||
'verbose_name': 'دسته\u200cبندی فروشگاه',
|
||
'verbose_name_plural': 'دسته\u200cبندی\u200cهای فروشگاه',
|
||
'ordering': ['order', 'name'],
|
||
},
|
||
),
|
||
migrations.CreateModel(
|
||
name='Store',
|
||
fields=[
|
||
('uuid', models.UUIDField(db_index=True, default=uuid.uuid4, primary_key=True, serialize=False, unique=True)),
|
||
('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
|
||
('updated_at', models.DateTimeField(auto_now=True, db_index=True)),
|
||
('name', models.CharField(max_length=150)),
|
||
('description', models.TextField(blank=True)),
|
||
('logo', models.ImageField(blank=True, null=True, upload_to='store_logos/')),
|
||
('cover_image', models.ImageField(blank=True, null=True, upload_to='store_covers/')),
|
||
('phone_number', models.CharField(blank=True, max_length=20)),
|
||
('address', models.TextField()),
|
||
('location', django.contrib.gis.db.models.fields.PointField(blank=True, geography=True, null=True, srid=4326)),
|
||
('delivery_radius_km', models.DecimalField(decimal_places=2, default=5, max_digits=5)),
|
||
('min_order_amount', models.PositiveBigIntegerField(default=0)),
|
||
('delivery_fee', models.PositiveBigIntegerField(default=0)),
|
||
('free_delivery_threshold', models.PositiveBigIntegerField(blank=True, null=True)),
|
||
('commission_percent', models.DecimalField(blank=True, decimal_places=2, help_text='در صورت خالی بودن، از DEFAULT_COMMISSION_PERCENT استفاده می\u200cشود.', max_digits=5, null=True)),
|
||
('accepts_wallet', models.BooleanField(default=True)),
|
||
('accepts_online', models.BooleanField(default=True)),
|
||
('accepts_cash_on_delivery', models.BooleanField(default=True)),
|
||
('rating_avg', models.DecimalField(decimal_places=2, default=0, max_digits=3)),
|
||
('rating_count', models.PositiveIntegerField(default=0)),
|
||
('status', models.CharField(choices=[('pending', 'در انتظار تایید'), ('approved', 'تایید شده'), ('suspended', 'معلق شده')], default='pending', max_length=10)),
|
||
('is_open', models.BooleanField(default=True)),
|
||
('city', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='stores', to='locations.city')),
|
||
('owner', models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, related_name='store', to=settings.AUTH_USER_MODEL)),
|
||
('service_neighborhoods', models.ManyToManyField(blank=True, help_text='محله\u200cهایی که این فروشگاه به آن\u200cها ارسال دارد.', related_name='stores', to='locations.neighborhood')),
|
||
('category', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='stores', to='stores.storecategory')),
|
||
],
|
||
options={
|
||
'verbose_name': 'فروشگاه',
|
||
'verbose_name_plural': 'فروشگاه\u200cها',
|
||
'ordering': ['-created_at'],
|
||
},
|
||
),
|
||
migrations.CreateModel(
|
||
name='StoreBankAccount',
|
||
fields=[
|
||
('uuid', models.UUIDField(db_index=True, default=uuid.uuid4, primary_key=True, serialize=False, unique=True)),
|
||
('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
|
||
('updated_at', models.DateTimeField(auto_now=True, db_index=True)),
|
||
('iban', models.CharField(max_length=26, validators=[django.core.validators.RegexValidator('^IR\\d{24}$', 'شماره شبا معتبر نیست.')])),
|
||
('account_holder_name', models.CharField(max_length=150)),
|
||
('store', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='bank_account', to='stores.store')),
|
||
],
|
||
options={
|
||
'verbose_name': 'حساب بانکی فروشگاه',
|
||
'verbose_name_plural': 'حساب\u200cهای بانکی فروشگاه',
|
||
},
|
||
),
|
||
migrations.CreateModel(
|
||
name='StoreWorkingHours',
|
||
fields=[
|
||
('uuid', models.UUIDField(db_index=True, default=uuid.uuid4, primary_key=True, serialize=False, unique=True)),
|
||
('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
|
||
('updated_at', models.DateTimeField(auto_now=True, db_index=True)),
|
||
('weekday', models.PositiveSmallIntegerField(choices=[(0, 'شنبه'), (1, 'یکشنبه'), (2, 'دوشنبه'), (3, 'سه\u200cشنبه'), (4, 'چهارشنبه'), (5, 'پنجشنبه'), (6, 'جمعه')])),
|
||
('opens_at', models.TimeField(blank=True, null=True)),
|
||
('closes_at', models.TimeField(blank=True, null=True)),
|
||
('is_closed', models.BooleanField(default=False)),
|
||
('store', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='working_hours', to='stores.store')),
|
||
],
|
||
options={
|
||
'verbose_name': 'ساعت کاری فروشگاه',
|
||
'verbose_name_plural': 'ساعات کاری فروشگاه',
|
||
'ordering': ['weekday'],
|
||
'unique_together': {('store', 'weekday')},
|
||
},
|
||
),
|
||
]
|