devfzn
e3b750bd83
Clase Item con atributos stock y precio; metodos amount, manage_stock, check_stock, place_order. Clase Order con atributos user, item, quantity. Registro en panel de administración. Serializadores de Item y Order + excepción APIException del framework.
60 lines
3.1 KiB
Python
60 lines
3.1 KiB
Python
# Generated by Django 4.1.7 on 2023-03-30 18:07
|
|
|
|
from django.conf import settings
|
|
from django.db import migrations, models
|
|
import django.db.models.deletion
|
|
import django_extensions.db.fields
|
|
import uuid
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
initial = True
|
|
|
|
dependencies = [
|
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
]
|
|
|
|
operations = [
|
|
migrations.CreateModel(
|
|
name='Item',
|
|
fields=[
|
|
('id', models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False)),
|
|
('created', django_extensions.db.fields.CreationDateTimeField(auto_now_add=True, verbose_name='created')),
|
|
('modified', django_extensions.db.fields.ModificationDateTimeField(auto_now=True, verbose_name='modified')),
|
|
('title', models.CharField(max_length=255, verbose_name='title')),
|
|
('description', models.TextField(blank=True, null=True, verbose_name='description')),
|
|
('slug', django_extensions.db.fields.AutoSlugField(blank=True, editable=False, populate_from='title', verbose_name='slug')),
|
|
('status', models.IntegerField(choices=[(0, 'Inactive'), (1, 'Active')], default=1, verbose_name='status')),
|
|
('activate_date', models.DateTimeField(blank=True, help_text='keep empty for an immediate activation', null=True)),
|
|
('deactivate_date', models.DateTimeField(blank=True, help_text='keep empty for indefinite activation', null=True)),
|
|
('stock', models.IntegerField(default=1)),
|
|
('price', models.IntegerField(default=0)),
|
|
],
|
|
options={
|
|
'verbose_name': 'Item',
|
|
'verbose_name_plural': 'Items',
|
|
'ordering': ['id'],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name='Order',
|
|
fields=[
|
|
('id', models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False)),
|
|
('created', django_extensions.db.fields.CreationDateTimeField(auto_now_add=True, verbose_name='created')),
|
|
('modified', django_extensions.db.fields.ModificationDateTimeField(auto_now=True, verbose_name='modified')),
|
|
('status', models.IntegerField(choices=[(0, 'Inactive'), (1, 'Active')], default=1, verbose_name='status')),
|
|
('activate_date', models.DateTimeField(blank=True, help_text='keep empty for an immediate activation', null=True)),
|
|
('deactivate_date', models.DateTimeField(blank=True, help_text='keep empty for indefinite activation', null=True)),
|
|
('quantity', models.IntegerField(default=0)),
|
|
('item', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='ecommerce.item')),
|
|
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
|
],
|
|
options={
|
|
'verbose_name': 'Order',
|
|
'verbose_name_plural': 'Orders',
|
|
'ordering': ['id'],
|
|
},
|
|
),
|
|
]
|