This commit is contained in:
2026-05-12 19:35:15 +03:00
parent c451a106a1
commit 0fdb8b8a02
17 changed files with 1351 additions and 8 deletions

View File

@@ -0,0 +1,193 @@
# Generated by Django 6.0.5 on 2026-05-12 15:32
import apps.submissions.models
import django.core.validators
import django.db.models.deletion
import uuid
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="Filament",
fields=[
(
"id",
models.UUIDField(
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
),
),
(
"material",
models.CharField(
choices=[
("PLA", "PLA"),
("PLA+", "PLA+"),
("PETG", "PETG"),
("ABS", "ABS"),
("TPU", "TPU"),
("ASA", "ASA"),
("Nylon", "Nylon"),
("Other", "Other"),
],
max_length=16,
),
),
("color_name", models.CharField(max_length=64)),
(
"swatch_hex",
models.CharField(blank=True, help_text="#RRGGBB", max_length=7),
),
("is_available", models.BooleanField(default=True)),
("notes", models.CharField(blank=True, max_length=200)),
("sort_order", models.IntegerField(default=0)),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
],
options={
"ordering": ("sort_order", "color_name"),
"indexes": [
models.Index(
fields=["is_available"], name="submissions_is_avai_6de7b0_idx"
),
models.Index(
fields=["sort_order", "color_name"],
name="submissions_sort_or_59555c_idx",
),
],
},
),
migrations.CreateModel(
name="Submission",
fields=[
(
"id",
models.UUIDField(
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
),
),
("slug", models.CharField(db_index=True, max_length=64, unique=True)),
(
"guest_email",
models.EmailField(blank=True, max_length=254, null=True),
),
("email_confirmed", models.BooleanField(default=False)),
(
"confirmation_token",
models.CharField(
blank=True, db_index=True, max_length=64, null=True
),
),
("confirmation_sent_at", models.DateTimeField(blank=True, null=True)),
(
"source_type",
models.CharField(
choices=[
("upload", "Raw .stl upload"),
("printables", "Printables.com"),
("makerworld", "MakerWorld"),
("thingiverse", "Thingiverse"),
],
default="upload",
max_length=16,
),
),
(
"stl_file",
models.FileField(
blank=True,
null=True,
upload_to="stl/",
validators=[
django.core.validators.FileExtensionValidator(
allowed_extensions=["stl"]
),
apps.submissions.models._validate_stl_size,
],
),
),
("source_url", models.URLField(blank=True, null=True)),
("notes_for_op", models.TextField(blank=True)),
(
"status",
models.CharField(
choices=[
("identifying", "Identifying"),
("processing", "Processing"),
("verifying", "Verifying"),
("queued", "Queued"),
("printing", "Printing"),
("completed", "Completed"),
("rejected", "Rejected"),
("failed", "Failed"),
],
db_index=True,
default="identifying",
max_length=16,
),
),
("operator_notes", models.TextField(blank=True)),
("closed_at", models.DateTimeField(blank=True, null=True)),
("created_at", models.DateTimeField(auto_now_add=True, db_index=True)),
("updated_at", models.DateTimeField(auto_now=True)),
(
"closed_by",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="closed_submissions",
to=settings.AUTH_USER_MODEL,
),
),
(
"requested_filament",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="submissions",
to="submissions.filament",
),
),
(
"submitted_by",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="submissions",
to=settings.AUTH_USER_MODEL,
),
),
],
options={
"ordering": ("-created_at",),
"constraints": [
models.CheckConstraint(
condition=models.Q(
("submitted_by__isnull", False),
("guest_email__isnull", False),
_connector="OR",
),
name="submission_has_contact_identity",
)
],
},
),
]