244 lines
8.6 KiB
Python
244 lines
8.6 KiB
Python
# Generated by Django 5.2.19 on 2026-11-14 08:53
|
|
|
|
import django.core.validators
|
|
import django.db.models.deletion
|
|
from django.conf import settings
|
|
from django.db import migrations, models
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
initial = True
|
|
|
|
dependencies = [
|
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
]
|
|
|
|
operations = [
|
|
migrations.CreateModel(
|
|
name="Color",
|
|
fields=[
|
|
(
|
|
"id",
|
|
models.BigAutoField(
|
|
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
|
|
),
|
|
),
|
|
("name", models.CharField(max_length=100, unique=True, verbose_name="Farbe")),
|
|
],
|
|
options={
|
|
"verbose_name": "Farbe",
|
|
"verbose_name_plural": "Farben",
|
|
"ordering": ["name"],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name="Manufacturer",
|
|
fields=[
|
|
(
|
|
"id",
|
|
models.BigAutoField(
|
|
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
|
|
),
|
|
),
|
|
("name", models.CharField(max_length=100, unique=True, verbose_name="Hersteller")),
|
|
],
|
|
options={
|
|
"verbose_name": "Hersteller",
|
|
"verbose_name_plural": "Hersteller",
|
|
"ordering": ["name"],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name="ProductType",
|
|
fields=[
|
|
(
|
|
"id",
|
|
models.BigAutoField(
|
|
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
|
|
),
|
|
),
|
|
("name", models.CharField(max_length=100, verbose_name="Produktart")),
|
|
(
|
|
"manufacturer",
|
|
models.ForeignKey(
|
|
on_delete=django.db.models.deletion.PROTECT,
|
|
to="filament.manufacturer",
|
|
verbose_name="Hersteller",
|
|
),
|
|
),
|
|
],
|
|
options={
|
|
"verbose_name": "Produktart",
|
|
"verbose_name_plural": "Produktarten",
|
|
"ordering": ["manufacturer__name", "name"],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name="Variant",
|
|
fields=[
|
|
(
|
|
"id",
|
|
models.BigAutoField(
|
|
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
|
|
),
|
|
),
|
|
(
|
|
"spool_type",
|
|
models.CharField(
|
|
choices=[("spool", "Mit Spule"), ("refill", "Refill (ohne Spule)")],
|
|
max_length=10,
|
|
verbose_name="Spulenausführung",
|
|
),
|
|
),
|
|
(
|
|
"manufacturer_color_code",
|
|
models.CharField(blank=True, max_length=40, verbose_name="Hersteller-Farbcode"),
|
|
),
|
|
(
|
|
"net_weight_g",
|
|
models.PositiveIntegerField(
|
|
blank=True,
|
|
null=True,
|
|
validators=[django.core.validators.MinValueValidator(1)],
|
|
verbose_name="Nettogewicht (g)",
|
|
),
|
|
),
|
|
(
|
|
"diameter_mm",
|
|
models.DecimalField(
|
|
blank=True,
|
|
decimal_places=2,
|
|
max_digits=4,
|
|
null=True,
|
|
validators=[django.core.validators.MinValueValidator(0.01)],
|
|
verbose_name="Durchmesser (mm)",
|
|
),
|
|
),
|
|
("is_active", models.BooleanField(default=True, verbose_name="Aktiv")),
|
|
(
|
|
"color",
|
|
models.ForeignKey(
|
|
on_delete=django.db.models.deletion.PROTECT,
|
|
related_name="variants",
|
|
to="filament.color",
|
|
verbose_name="Farbe",
|
|
),
|
|
),
|
|
(
|
|
"product_type",
|
|
models.ForeignKey(
|
|
on_delete=django.db.models.deletion.PROTECT,
|
|
related_name="variants",
|
|
to="filament.producttype",
|
|
verbose_name="Produktart",
|
|
),
|
|
),
|
|
],
|
|
options={
|
|
"verbose_name": "Filamentvariante",
|
|
"verbose_name_plural": "Filamentvarianten",
|
|
"ordering": [
|
|
"product_type__manufacturer__name",
|
|
"product_type__name",
|
|
"color__name",
|
|
"spool_type",
|
|
],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name="InventoryItem",
|
|
fields=[
|
|
(
|
|
"id",
|
|
models.BigAutoField(
|
|
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
|
|
),
|
|
),
|
|
(
|
|
"quantity",
|
|
models.PositiveIntegerField(
|
|
validators=[
|
|
django.core.validators.MinValueValidator(1),
|
|
django.core.validators.MaxValueValidator(9999),
|
|
],
|
|
verbose_name="Stückzahl",
|
|
),
|
|
),
|
|
(
|
|
"owner",
|
|
models.ForeignKey(
|
|
on_delete=django.db.models.deletion.CASCADE,
|
|
to=settings.AUTH_USER_MODEL,
|
|
verbose_name="Person",
|
|
),
|
|
),
|
|
(
|
|
"variant",
|
|
models.ForeignKey(
|
|
on_delete=django.db.models.deletion.PROTECT,
|
|
to="filament.variant",
|
|
verbose_name="Filamentvariante",
|
|
),
|
|
),
|
|
],
|
|
options={
|
|
"ordering": [
|
|
"variant__product_type__manufacturer__name",
|
|
"variant__product_type__name",
|
|
"variant__color__name",
|
|
"variant__spool_type",
|
|
],
|
|
"abstract": False,
|
|
},
|
|
),
|
|
migrations.AddConstraint(
|
|
model_name="producttype",
|
|
constraint=models.UniqueConstraint(
|
|
fields=("manufacturer", "name"), name="unique_product_per_manufacturer"
|
|
),
|
|
),
|
|
migrations.AddConstraint(
|
|
model_name="variant",
|
|
constraint=models.UniqueConstraint(
|
|
fields=("product_type", "color", "spool_type"), name="unique_catalog_variant"
|
|
),
|
|
),
|
|
migrations.AddConstraint(
|
|
model_name="variant",
|
|
constraint=models.CheckConstraint(
|
|
condition=models.Q(("spool_type__in", ["spool", "refill"])), name="valid_spool_type"
|
|
),
|
|
),
|
|
migrations.AddConstraint(
|
|
model_name="variant",
|
|
constraint=models.CheckConstraint(
|
|
condition=models.Q(
|
|
("net_weight_g__isnull", True), ("net_weight_g__gt", 0), _connector="OR"
|
|
),
|
|
name="positive_net_weight",
|
|
),
|
|
),
|
|
migrations.AddConstraint(
|
|
model_name="variant",
|
|
constraint=models.CheckConstraint(
|
|
condition=models.Q(
|
|
("diameter_mm__isnull", True), ("diameter_mm__gt", 0), _connector="OR"
|
|
),
|
|
name="positive_diameter",
|
|
),
|
|
),
|
|
migrations.AddConstraint(
|
|
model_name="inventoryitem",
|
|
constraint=models.UniqueConstraint(
|
|
fields=("owner", "variant"), name="inventoryitem_owner_variant"
|
|
),
|
|
),
|
|
migrations.AddConstraint(
|
|
model_name="inventoryitem",
|
|
constraint=models.CheckConstraint(
|
|
condition=models.Q(("quantity__gte", 1), ("quantity__lte", 9999)),
|
|
name="inventoryitem_quantity_range",
|
|
),
|
|
),
|
|
]
|