made cleaner migrations for loans

This commit is contained in:
Sylvain Gay 2024-05-02 11:31:34 +02:00
parent 474083dd38
commit 67c64c0d1c
5 changed files with 33 additions and 36 deletions

View file

@ -1,5 +1,6 @@
# Generated by Django 4.2.8 on 2024-04-30 15:24
# Generated by Django 4.2.8 on 2024-05-02 09:30
import autoslug.fields
from django.db import migrations, models
import django.db.models.deletion
@ -7,7 +8,6 @@ import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('loans', '0002_abstractloan_delete_loan'),
('inventory', '0002_duration_range'),
]
@ -15,9 +15,18 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='GameLoan',
fields=[
('abstractloan_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='loans.abstractloan')),
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('slug', autoslug.fields.AutoSlugField(editable=False, populate_from='lent_object', unique=True)),
('borrow_date', models.DateTimeField(auto_now_add=True)),
('return_date', models.DateTimeField(null=True)),
('mail', models.EmailField(max_length=254)),
('lent_object', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='inventory.game', verbose_name='jeu emprunté')),
],
bases=('loans.abstractloan',),
options={
'verbose_name': 'emprunt',
'verbose_name_plural': 'emprunts',
'ordering': ['borrow_date'],
'abstract': False,
},
),
]

View file

@ -159,3 +159,6 @@ class GameLoan(AbstractLoan):
Game, on_delete=models.CASCADE,
verbose_name="jeu emprunté"
)
class Meta(AbstractLoan.Meta):
abstract = False

View file

@ -1,32 +0,0 @@
# Generated by Django 4.2.8 on 2024-04-30 15:24
import autoslug.fields
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('loans', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='AbstractLoan',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('slug', autoslug.fields.AutoSlugField(editable=False, populate_from='game', unique=True)),
('borrow_date', models.DateTimeField(auto_now_add=True)),
('return_date', models.DateTimeField(null=True)),
('mail', models.EmailField(max_length=254)),
],
options={
'verbose_name': 'emprunt',
'verbose_name_plural': 'emprunts',
'ordering': ['borrow_date'],
},
),
migrations.DeleteModel(
name='Loan',
),
]

View file

@ -0,0 +1,16 @@
# Generated by Django 4.2.8 on 2024-05-02 09:30
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('loans', '0001_initial'),
]
operations = [
migrations.DeleteModel(
name='Loan',
),
]

View file

@ -12,6 +12,7 @@ class AbstractLoan(models.Model):
lent_object_slug_field = "slug"
class Meta:
abstract = True
ordering=["borrow_date"]
verbose_name = "emprunt"
verbose_name_plural = "emprunts"