45 lines
2.8 KiB
Python
45 lines
2.8 KiB
Python
# Generated by Django 5.1.15 on 2026-05-02 15:36
|
|
|
|
import django.db.models.deletion
|
|
from django.conf import settings
|
|
from django.db import migrations, models
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
initial = True
|
|
|
|
dependencies = [
|
|
('courses', '0002_course_original_price_toman_course_price_toman'),
|
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
]
|
|
|
|
operations = [
|
|
migrations.CreateModel(
|
|
name='Order',
|
|
fields=[
|
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
('amount_toman', models.PositiveIntegerField(verbose_name='amount (Toman)')),
|
|
('ilo_fee_toman', models.PositiveIntegerField(default=0, verbose_name='platform fee (Toman)')),
|
|
('instructor_share_toman', models.PositiveIntegerField(default=0, verbose_name='instructor share (Toman)')),
|
|
('commission_percent_snapshot', models.PositiveSmallIntegerField(default=0, verbose_name='commission % at order time')),
|
|
('gateway', models.CharField(choices=[('console', 'Console (dev)'), ('zarinpal', 'ZarinPal')], max_length=16, verbose_name='gateway')),
|
|
('authority', models.CharField(blank=True, db_index=True, max_length=100, verbose_name='authority')),
|
|
('ref_id', models.CharField(blank=True, max_length=64, verbose_name='ref ID')),
|
|
('status', models.CharField(choices=[('pending', 'Pending'), ('paid', 'Paid'), ('failed', 'Failed'), ('cancelled', 'Cancelled')], default='pending', max_length=16, verbose_name='status')),
|
|
('created_at', models.DateTimeField(auto_now_add=True, verbose_name='created at')),
|
|
('paid_at', models.DateTimeField(blank=True, null=True, verbose_name='paid at')),
|
|
('failed_at', models.DateTimeField(blank=True, null=True, verbose_name='failed at')),
|
|
('last_error', models.CharField(blank=True, max_length=255, verbose_name='last error')),
|
|
('course', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='orders', to='courses.course')),
|
|
('student', models.ForeignKey(limit_choices_to={'role': 'student'}, on_delete=django.db.models.deletion.PROTECT, related_name='orders', to=settings.AUTH_USER_MODEL)),
|
|
],
|
|
options={
|
|
'verbose_name': 'order',
|
|
'verbose_name_plural': 'orders',
|
|
'ordering': ['-created_at'],
|
|
'indexes': [models.Index(fields=['student', '-created_at'], name='payments_or_student_4b23c9_idx'), models.Index(fields=['course', '-created_at'], name='payments_or_course__78a038_idx'), models.Index(fields=['status'], name='payments_or_status_daab12_idx')],
|
|
},
|
|
),
|
|
]
|