# Generated by Django 5.1.2 on 2025-04-07 04:19

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('accounts', '0001_initial'),
        ('cards', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='TradeOffer',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False)),
                ('is_closed', models.BooleanField(db_index=True, default=False)),
                ('hash', models.CharField(editable=False, max_length=9)),
                ('rarity_icon', models.CharField(max_length=8, null=True)),
                ('rarity_level', models.IntegerField(null=True)),
                ('image', models.ImageField(blank=True, null=True, upload_to='trade_offers/')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('initiated_by', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='initiated_trade_offers', to='accounts.friendcode')),
            ],
        ),
        migrations.CreateModel(
            name='TradeAcceptance',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('state', models.CharField(choices=[('ACCEPTED', 'Accepted'), ('SENT', 'Sent'), ('RECEIVED', 'Received'), ('THANKED_BY_INITIATOR', 'Thanked by Initiator'), ('THANKED_BY_ACCEPTOR', 'Thanked by Acceptor'), ('THANKED_BY_BOTH', 'Thanked by Both'), ('REJECTED_BY_INITIATOR', 'Rejected by Initiator'), ('REJECTED_BY_ACCEPTOR', 'Rejected by Acceptor')], default='ACCEPTED', max_length=25)),
                ('hash', models.CharField(blank=True, editable=False, max_length=9)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('accepted_by', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='trade_acceptances', to='accounts.friendcode')),
                ('offered_card', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='accepted_offered', to='cards.card')),
                ('requested_card', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='accepted_requested', to='cards.card')),
                ('trade_offer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='acceptances', to='trades.tradeoffer')),
            ],
        ),
        migrations.CreateModel(
            name='TradeOfferHaveCard',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('quantity', models.PositiveIntegerField(default=1)),
                ('qty_accepted', models.PositiveIntegerField(default=0, editable=False)),
                ('card', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='cards.card')),
                ('trade_offer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='trade_offer_have_cards', to='trades.tradeoffer')),
            ],
            options={
                'unique_together': {('trade_offer', 'card')},
            },
        ),
        migrations.AddField(
            model_name='tradeoffer',
            name='have_cards',
            field=models.ManyToManyField(related_name='trade_offers_have', through='trades.TradeOfferHaveCard', to='cards.card'),
        ),
        migrations.CreateModel(
            name='TradeOfferWantCard',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('quantity', models.PositiveIntegerField(default=1)),
                ('qty_accepted', models.PositiveIntegerField(default=0, editable=False)),
                ('card', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='cards.card')),
                ('trade_offer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='trade_offer_want_cards', to='trades.tradeoffer')),
            ],
            options={
                'unique_together': {('trade_offer', 'card')},
            },
        ),
        migrations.AddField(
            model_name='tradeoffer',
            name='want_cards',
            field=models.ManyToManyField(related_name='trade_offers_want', through='trades.TradeOfferWantCard', to='cards.card'),
        ),
    ]
