Add generic filament catalog under Sonstige

This commit is contained in:
Mikei386 committed 2026-11-14 19:23:58 +01:00
1 parent 8ebfaa7e2a
commit cd04de8b76
4 files changed
+110 -4

No files matched your search

+7 -2
View File
@@ -24,8 +24,8 @@ Keine SPA, keine externen Schriften/Skripte, kein externer Datenbankserver.
- Die Bestellhistorie zeigt die bestellten, eingetroffenen und übergebenen Positionen der Gruppe.
Bestell- und Übergabezeitpunkte werden bei den jeweiligen Statuswechseln gespeichert.
- Deaktivierte Varianten bleiben in vorhandenen Positionen sichtbar, sind nicht neu wählbar.
- Einmalig ladbare Startkataloge für Bambu Lab, SUNLU, eSUN, JAYO, Anycubic und Geeetech
sowie konsistentes SQLite-Online-Backup.
- Einmalig ladbare Startkataloge für Bambu Lab, SUNLU, eSUN, JAYO, Anycubic, Geeetech
und Sonstige sowie konsistentes SQLite-Online-Backup.
Unter „Spule verbraucht“ lässt sich eine Rolle ausbuchen und optional ihre Katalogvariante
in die Sammelbestellung übernehmen. Die Sammelbestellung ist eine Planungsliste.
@@ -363,6 +363,11 @@ EU-Varianten aus 14 Shop-Produktreihen mit 1,75 mm Durchmesser und 1 kg pro Spul
Im Katalog bilden die PLA-CF-Farben eine eigene Unterart. Alle Varianten haben eine
Artikelnummer. Der Feed ordnet 166 Varianten ein Produktbild zu. Stand 14. November 2026.
**Sonstige** bietet PLA, ABS, PETG, ASA und TPU mit der Unterart **Standard**.
Alle neun Grundfarben stehen mit und ohne Spule zur Auswahl. Die Farbvorschauen sind
generisch. Artikelnummer, Nettogewicht und Durchmesser sind offen, und die App verwendet
den Platzhalter für Produktbilder.
Die Datenstände werden mit dem Programm ausgeliefert und beim Start nicht aus dem Shop nachgeladen.
Der erste erfolgreiche Import wird je Hersteller in der Datenbank markiert. Spätere Aufrufe überspringen
den Import vollständig, sodass lokale Löschungen, Deaktivierungen, Umbenennungen und Ergänzungen
+23
View File
@@ -0,0 +1,23 @@
"""Brand-neutral starter variants with illustrative color previews."""
MATERIALS = ("PLA", "ABS", "PETG", "ASA", "TPU")
COLORS = {
"Weiß": "#FFFFFF",
"Schwarz": "#222222",
"Grau": "#808080",
"Rot": "#D62828",
"Gelb": "#F4C430",
"Grün": "#228B22",
"Blau": "#2463BB",
"Orange": "#EF791D",
"Braun": "#805432",
}
GENERIC_CATALOG = {
f"{material} Standard": tuple(
(color, spool_type, "", None, swatch, "")
for color, swatch in COLORS.items()
for spool_type in ("spool", "refill")
)
for material in MATERIALS
}
+20 -2
View File
@@ -11,6 +11,7 @@ from filament.bambu_pla_pure_catalog import BAMBU_PLA_PURE_CATALOG
from filament.bambu_swatches_0005 import BAMBU_SWATCHES
from filament.esun_catalog import ESUN_CATALOG
from filament.geeetech_catalog import GEEETECH_CATALOG
from filament.generic_catalog import GENERIC_CATALOG
from filament.jayo_catalog import JAYO_CATALOG
from filament.models import CatalogBootstrap, Color, Manufacturer, ProductType, Variant
from filament.sunlu_catalog import SUNLU_CATALOG, SUNLU_IMAGE_BASE
@@ -23,6 +24,7 @@ ESUN_BOOTSTRAP_KEY = "esun-eu-initial-catalog"
JAYO_BOOTSTRAP_KEY = "jayo-eu-initial-catalog"
ANYCUBIC_BOOTSTRAP_KEY = "anycubic-de-initial-catalog"
GEEETECH_BOOTSTRAP_KEY = "geeetech-eu-initial-catalog"
GENERIC_BOOTSTRAP_KEY = "generic-initial-catalog"
class Command(BaseCommand):
@@ -57,6 +59,13 @@ class Command(BaseCommand):
GEEETECH_CATALOG,
shopify_image_url,
)
self.seed_catalog(
options["verbosity"],
GENERIC_BOOTSTRAP_KEY,
"Sonstige",
GENERIC_CATALOG,
diameter_mm=None,
)
@transaction.atomic
def seed_bambu(self, verbosity):
@@ -103,7 +112,16 @@ class Command(BaseCommand):
)
@transaction.atomic
def seed_catalog(self, verbosity, key, manufacturer_name, catalog, image_url=None):
def seed_catalog(
self,
verbosity,
key,
manufacturer_name,
catalog,
image_url=None,
*,
diameter_mm=Decimal("1.75"),
):
_, should_import = CatalogBootstrap.objects.get_or_create(key=key)
if not should_import:
return
@@ -121,7 +139,7 @@ class Command(BaseCommand):
defaults={
"manufacturer_color_code": sku,
"net_weight_g": weight,
"diameter_mm": Decimal("1.75"),
"diameter_mm": diameter_mm,
"swatch": swatch,
"image_url": image_url(image_path) if image_url else image_path,
},
+60
View File
@@ -9,6 +9,7 @@ from filament.management.commands.seed_catalog import (
BAMBU_PLA_PURE_BOOTSTRAP_KEY,
ESUN_BOOTSTRAP_KEY,
GEEETECH_BOOTSTRAP_KEY,
GENERIC_BOOTSTRAP_KEY,
JAYO_BOOTSTRAP_KEY,
SUNLU_BOOTSTRAP_KEY,
)
@@ -625,3 +626,62 @@ class CatalogTests(CatalogTestCase):
self.assertEqual(variants.count(), 169)
spool.refresh_from_db()
self.assertFalse(spool.is_active)
def test_sonstige_catalog_imports_once_and_is_selectable_in_both_forms(self):
CatalogBootstrap.objects.bulk_create(
CatalogBootstrap(key=key)
for key in (
ANYCUBIC_BOOTSTRAP_KEY,
BAMBU_LAB_BOOTSTRAP_KEY,
BAMBU_PETG_BOOTSTRAP_KEY,
BAMBU_PLA_PURE_BOOTSTRAP_KEY,
ESUN_BOOTSTRAP_KEY,
GEEETECH_BOOTSTRAP_KEY,
JAYO_BOOTSTRAP_KEY,
SUNLU_BOOTSTRAP_KEY,
)
)
call_command("seed_catalog", verbosity=0)
self.assertTrue(CatalogBootstrap.objects.filter(key=GENERIC_BOOTSTRAP_KEY).exists())
maker = Manufacturer.objects.get(name="Sonstige")
variants = Variant.objects.filter(product_type__manufacturer=maker)
materials = {"PLA", "ABS", "PETG", "ASA", "TPU"}
colors = {"Weiß", "Schwarz", "Grau", "Rot", "Gelb", "Grün", "Blau", "Orange", "Braun"}
self.assertEqual(
set(variants.values_list("product_type__name", "color__name", "spool_type")),
{
(f"{material} Standard", color, spool_type)
for material in materials
for color in colors
for spool_type in ("spool", "refill")
},
)
self.assertFalse(
variants.exclude(
manufacturer_color_code="", net_weight_g=None, diameter_mm=None, image_url=""
).exists()
)
self.assertFalse(variants.filter(swatch="").exists())
for url, model, spool_type in (
("/bestand/hinzufuegen/", InventoryItem, "spool"),
("/bestellung/hinzufuegen/", OrderItem, "refill"),
):
variant = variants.get(
product_type__name="ASA Standard", color__name="Grau", spool_type=spool_type
)
data = self.selection(variant)
response = self.client.post(url, data | {"action": "filter"})
form = response.context["form"]
self.assertEqual({key for key, _ in form.fields["material"].choices if key}, materials)
self.assertEqual(
[label for key, label in form.fields["product_type"].choices if key], ["Standard"]
)
self.assertEqual(set(dict(form.fields["spool_type"].choices)), {"spool", "refill"})
self.assertRedirects(self.client.post(url, data), url.removesuffix("hinzufuegen/"))
self.assertEqual(model.objects.get(owner=self.alice).variant, variant)
unused_variant = variants.get(
product_type__name="TPU Standard", color__name="Grün", spool_type="spool"
)
unused_variant.delete()
call_command("seed_catalog", verbosity=0)
self.assertEqual(variants.count(), 89)