Complete audited Bambu Lab EU filament catalog
This commit is contained in:
1 parent
a69df4b33e
commit
a85de26ee7
3 files changed
+520
-9
No files matched your search
@@ -0,0 +1,376 @@
|
||||
"""Ergänzungen zum Bambu-Lab-EU-Katalog vom 16. November 2026.
|
||||
|
||||
Produktvarianten und Bilder aus der offiziellen EU-Filamentkollektion.
|
||||
https://eu.store.bambulab.com/collections/bambu-lab-3d-printer-filament
|
||||
Farbwerte aus den offiziellen Bambu-Studio-Filamentdaten.
|
||||
https://github.com/bambulab/BambuStudio/blob/19843bf27197d55fb571e419aa58a29b60bab535/resources/profiles/BBL/filament/filaments_color_codes.json
|
||||
"""
|
||||
|
||||
BAMBU_EU_UPDATE = {
|
||||
"1.75": {
|
||||
"PETG-CF": (
|
||||
(
|
||||
"Titan Gray",
|
||||
"refill",
|
||||
"31101",
|
||||
1000,
|
||||
"#565656",
|
||||
"https://store.bblcdn.eu/s8/default/54bad3d608524461a7866c714fd3cb25/20231023-105314.png",
|
||||
),
|
||||
),
|
||||
"PLA Palette": (
|
||||
(
|
||||
"White",
|
||||
"spool",
|
||||
"18100",
|
||||
1000,
|
||||
"#FFFFFF",
|
||||
"https://store.bblcdn.eu/s8/default/c7fa0c44e60d49a385bf70d2495180f3/white.jpg",
|
||||
),
|
||||
(
|
||||
"Key",
|
||||
"spool",
|
||||
"18101",
|
||||
1000,
|
||||
"#000000",
|
||||
"https://store.bblcdn.eu/s8/default/f36e946da6ff4d56bedd7f5e850cc5b9/key.png",
|
||||
),
|
||||
(
|
||||
"Magenta",
|
||||
"spool",
|
||||
"18200",
|
||||
1000,
|
||||
"#E24585",
|
||||
"https://store.bblcdn.eu/s8/default/1b4f38b69ef74ef99d8508baea607842/magenta.jpg",
|
||||
),
|
||||
(
|
||||
"Yellow",
|
||||
"spool",
|
||||
"18400",
|
||||
1000,
|
||||
"#FCE300",
|
||||
"https://store.bblcdn.eu/s8/default/ea35ae9ef22f48ee8ffad751b873af7b/yellow.png",
|
||||
),
|
||||
(
|
||||
"Cyan",
|
||||
"spool",
|
||||
"18600",
|
||||
1000,
|
||||
"#0090DA",
|
||||
"https://store.bblcdn.eu/s8/default/df8d6c2be2c841a08944803965c9bcd2/cyan.jpg",
|
||||
),
|
||||
),
|
||||
"PLA Silk Dual Color": (
|
||||
(
|
||||
"South Beach",
|
||||
"spool",
|
||||
"13906",
|
||||
1000,
|
||||
"#F772A4,#00918B",
|
||||
"https://store.bblcdn.eu/s8/default/416c17ac9f3941e3aec8236380663d63/South_Beach.jpg",
|
||||
),
|
||||
(
|
||||
"Aurora-Lila",
|
||||
"spool",
|
||||
"13909",
|
||||
1000,
|
||||
"#7F3696,#006EC9",
|
||||
"https://store.bblcdn.eu/s8/default/a58bfc024a514af186b3ca6d2df2bcd5/Aurora_Purple_(1).jpg",
|
||||
),
|
||||
(
|
||||
"Dawn Radiance",
|
||||
"spool",
|
||||
"13912",
|
||||
1000,
|
||||
"",
|
||||
"https://store.bblcdn.eu/s8/default/f4c5a0fd47624f1bb4f8a55ab30f70e8/Dawn_Radiance.jpg",
|
||||
),
|
||||
(
|
||||
"Mystic Magenta",
|
||||
"spool",
|
||||
"13913",
|
||||
1000,
|
||||
"#720062,#3A913F",
|
||||
"https://store.bblcdn.eu/s8/default/d8c78612d63b43e7ae78a19d760744d0/Mystic_Magenta.jpg",
|
||||
),
|
||||
(
|
||||
"Phantom Blue",
|
||||
"spool",
|
||||
"13916",
|
||||
1000,
|
||||
"#00629B,#000000",
|
||||
"https://store.bblcdn.eu/s8/default/f3831103953f45998d186d9c048b1b7c/Phantom_Blue.jpg",
|
||||
),
|
||||
),
|
||||
"PLA Silk+": (
|
||||
(
|
||||
"Titan Gray",
|
||||
"refill",
|
||||
"13108",
|
||||
1000,
|
||||
"#5F6367",
|
||||
"https://store.bblcdn.eu/s8/default/9aaebe748b88497387f3c159307aa5bf/cf2723db072c4371b3606938b8cccdb9.jpg",
|
||||
),
|
||||
(
|
||||
"Silver",
|
||||
"refill",
|
||||
"13109",
|
||||
1000,
|
||||
"#C8C8C8",
|
||||
"https://store.bblcdn.eu/s8/default/7d86004d3ab3461cb446f1faa3c4c3e3/PLA_Silk_11.jpg",
|
||||
),
|
||||
(
|
||||
"White",
|
||||
"refill",
|
||||
"13110",
|
||||
1000,
|
||||
"#FFFFFF",
|
||||
"https://store.bblcdn.eu/s8/default/9f2542f1b7a34d9096655cd8788d2ae5/PLA_Silk_6.jpg",
|
||||
),
|
||||
(
|
||||
"Gold",
|
||||
"refill",
|
||||
"13405",
|
||||
1000,
|
||||
"#F4A925",
|
||||
"https://store.bblcdn.eu/s8/default/a389e82dffba45b7b9729a20afc2a80d/PLA_Silk_8.jpg",
|
||||
),
|
||||
),
|
||||
"PLA Tough+": (
|
||||
(
|
||||
"Black",
|
||||
"refill",
|
||||
"12104",
|
||||
1000,
|
||||
"#000000",
|
||||
"https://store.bblcdn.eu/s8/default/42bb57e8d1424530be92b0cf8c252fd5/PLA_Tough_(2).jpg",
|
||||
),
|
||||
(
|
||||
"Black",
|
||||
"spool",
|
||||
"12104",
|
||||
1000,
|
||||
"#000000",
|
||||
"https://store.bblcdn.eu/s8/default/42bb57e8d1424530be92b0cf8c252fd5/PLA_Tough_(2).jpg",
|
||||
),
|
||||
(
|
||||
"Gray",
|
||||
"refill",
|
||||
"12105",
|
||||
1000,
|
||||
"#AFB1AE",
|
||||
"https://store.bblcdn.eu/s8/default/a88104a53799478db5603f76524d833b/PLA_Tough_(1).jpg",
|
||||
),
|
||||
(
|
||||
"Gray",
|
||||
"spool",
|
||||
"12105",
|
||||
1000,
|
||||
"#AFB1AE",
|
||||
"https://store.bblcdn.eu/s8/default/a88104a53799478db5603f76524d833b/PLA_Tough_(1).jpg",
|
||||
),
|
||||
(
|
||||
"Silver",
|
||||
"spool",
|
||||
"12106",
|
||||
1000,
|
||||
"#959698",
|
||||
"https://store.bblcdn.eu/s8/default/0107d882ca3b462981680c380ff53370/PLA_Tough_(2).jpg",
|
||||
),
|
||||
(
|
||||
"White",
|
||||
"refill",
|
||||
"12107",
|
||||
1000,
|
||||
"#FFFFFF",
|
||||
"https://store.bblcdn.eu/s8/default/eeeff48a95b04c5888ee3fddc2d830be/PLA_Tough_new.jpg",
|
||||
),
|
||||
(
|
||||
"White",
|
||||
"spool",
|
||||
"12107",
|
||||
1000,
|
||||
"#FFFFFF",
|
||||
"https://store.bblcdn.eu/s8/default/eeeff48a95b04c5888ee3fddc2d830be/PLA_Tough_new.jpg",
|
||||
),
|
||||
(
|
||||
"Orange",
|
||||
"spool",
|
||||
"12301",
|
||||
1000,
|
||||
"#DC3A27",
|
||||
"https://store.bblcdn.eu/s8/default/e0c0dacfe71a4e5795d008b8df8995ba/PLA_Tough_(5).jpg",
|
||||
),
|
||||
(
|
||||
"Yellow",
|
||||
"spool",
|
||||
"12401",
|
||||
1000,
|
||||
"#F4D53F",
|
||||
"https://store.bblcdn.eu/s8/default/76a53975eaab4238ab610612c4efdc5f/PLA_Tough_(3).jpg",
|
||||
),
|
||||
(
|
||||
"Cyan",
|
||||
"spool",
|
||||
"12601",
|
||||
1000,
|
||||
"#009BD8",
|
||||
"https://store.bblcdn.eu/s8/default/0e011944be0f463da0ab267dc981db97/PLA_Tough_(4).jpg",
|
||||
),
|
||||
),
|
||||
"TPU 85A": (
|
||||
(
|
||||
"Black",
|
||||
"spool",
|
||||
"51107",
|
||||
1000,
|
||||
"#000000",
|
||||
"https://store.bblcdn.eu/s8/default/2e5453e39da34b45b5d8e6d54ae7fcf4/BLACK.jpg",
|
||||
),
|
||||
(
|
||||
"Rose Beige/Flesh",
|
||||
"spool",
|
||||
"51201",
|
||||
1000,
|
||||
"#F3CFB2",
|
||||
"https://store.bblcdn.eu/s8/default/5c2b2d6f888c4340aff00c078acd0db3/flesh.jpg",
|
||||
),
|
||||
(
|
||||
"Lime Green",
|
||||
"spool",
|
||||
"51501",
|
||||
1000,
|
||||
"#CDEA80",
|
||||
"https://store.bblcdn.eu/s8/default/e1f3d4ef598b42a2995f220718893d32/lime_green_(2).jpg",
|
||||
),
|
||||
),
|
||||
"TPU 90A": (
|
||||
(
|
||||
"Quicksilver",
|
||||
"spool",
|
||||
"51106",
|
||||
1000,
|
||||
"#9EA2A2",
|
||||
"https://store.bblcdn.eu/s8/default/a6a50e4e7a4b42c2bc7b430dfb5cafd4/silver_2.png",
|
||||
),
|
||||
(
|
||||
"Crystal Blue",
|
||||
"spool",
|
||||
"51601",
|
||||
1000,
|
||||
"#7EB4E1",
|
||||
"https://store.bblcdn.eu/s8/default/0c15199091134d2f92c0ea8ee90a5e51/Crystal_Blue.jpg",
|
||||
),
|
||||
(
|
||||
"Grape Jelly",
|
||||
"spool",
|
||||
"51700",
|
||||
1000,
|
||||
"#D6ABFF",
|
||||
"https://store.bblcdn.eu/s8/default/14c747cef36040bda1a8f7caffaa48cf/grape_jelly.jpg",
|
||||
),
|
||||
(
|
||||
"Cocoa Brown",
|
||||
"spool",
|
||||
"51800",
|
||||
1000,
|
||||
"#5C4738",
|
||||
"https://store.bblcdn.eu/s8/default/8ab92eac89be46ed872419cd6a0ec0a1/Cocoa_Brown.jpg",
|
||||
),
|
||||
),
|
||||
"TPU for AMS": (
|
||||
(
|
||||
"Black",
|
||||
"refill",
|
||||
"53101",
|
||||
1000,
|
||||
"#000000",
|
||||
"https://store.bblcdn.eu/s8/default/652b55d597184e208bda6486d980c2cf/7.jpg",
|
||||
),
|
||||
),
|
||||
},
|
||||
"2.85": {
|
||||
"TPU 75A (2.85mm)": (
|
||||
(
|
||||
"Black",
|
||||
"spool",
|
||||
"56100",
|
||||
1000,
|
||||
"#000000",
|
||||
"https://store.bblcdn.eu/s8/default/2aeb488e78bf47f2a23c8da7424329fd/black.jpg",
|
||||
),
|
||||
(
|
||||
"Red",
|
||||
"spool",
|
||||
"56200",
|
||||
1000,
|
||||
"#E4002B",
|
||||
"https://store.bblcdn.eu/s8/default/00f99416118645e09c86bee34e18a6e0/red.jpg",
|
||||
),
|
||||
(
|
||||
"Mandarin Orange",
|
||||
"spool",
|
||||
"56300",
|
||||
1000,
|
||||
"#FFA06A",
|
||||
"https://store.bblcdn.eu/s8/default/ce3bb28493214fc48b9b0e28dd6ebd7d/mandarin_orange.jpg",
|
||||
),
|
||||
(
|
||||
"Lemon Yellow",
|
||||
"spool",
|
||||
"56400",
|
||||
1000,
|
||||
"#FBDB65",
|
||||
"https://store.bblcdn.eu/s8/default/4eb0212ba87e431b9d87f16d01df2e2b/lemon_yellow.jpg",
|
||||
),
|
||||
(
|
||||
"Dark Ivory",
|
||||
"spool",
|
||||
"56401",
|
||||
1000,
|
||||
"#F1E6B2",
|
||||
"https://store.bblcdn.eu/s8/default/392ed48c0dec478794f9cfcec7e8e133/dark_ivory.jpg",
|
||||
),
|
||||
(
|
||||
"Dark Green",
|
||||
"spool",
|
||||
"56500",
|
||||
1000,
|
||||
"#617354",
|
||||
"https://store.bblcdn.eu/s8/default/c6a04c417bc8465980f21303854883b7/dark_green.jpg",
|
||||
),
|
||||
(
|
||||
"Grass Green",
|
||||
"spool",
|
||||
"56501",
|
||||
1000,
|
||||
"#7CCC6C",
|
||||
"https://store.bblcdn.eu/s8/default/8242cc49754f4330aad113f7f9107f28/grass_green.jpg",
|
||||
),
|
||||
(
|
||||
"Cyan",
|
||||
"spool",
|
||||
"56600",
|
||||
1000,
|
||||
"#00A3E1",
|
||||
"https://store.bblcdn.eu/s8/default/81dd7ea52aac496aa1c54c9fa257230d/cyan.jpg",
|
||||
),
|
||||
(
|
||||
"Purple",
|
||||
"spool",
|
||||
"56700",
|
||||
1000,
|
||||
"#AD96DC",
|
||||
"https://store.bblcdn.eu/s8/default/8475c4045f904632b5b0d7ddec87cf9e/purple.jpg",
|
||||
),
|
||||
(
|
||||
"Pink",
|
||||
"spool",
|
||||
"56701",
|
||||
1000,
|
||||
"#FABBCB",
|
||||
"https://store.bblcdn.eu/s8/default/4f69dae81de444b8b5c65cf62ac94e58/pink.jpg",
|
||||
),
|
||||
),
|
||||
},
|
||||
}
|
||||
@@ -5,6 +5,8 @@ from django.db import transaction
|
||||
|
||||
from filament.anycubic_catalog import ANYCUBIC_CATALOG
|
||||
from filament.bambu_catalog import BAMBU_LAB_CATALOG, BAMBU_LAB_VARIANT_COUNT
|
||||
from filament.bambu_color_names import PLA_SILK_DUAL_COLOR_CODES
|
||||
from filament.bambu_eu_catalog_update import BAMBU_EU_UPDATE
|
||||
from filament.bambu_images_0006 import bambu_image_url
|
||||
from filament.bambu_petg_catalog import BAMBU_PETG_CATALOG
|
||||
from filament.bambu_pla_pure_catalog import BAMBU_PLA_PURE_CATALOG
|
||||
@@ -19,6 +21,7 @@ from filament.sunlu_catalog import SUNLU_CATALOG, SUNLU_IMAGE_BASE
|
||||
BAMBU_LAB_BOOTSTRAP_KEY = "bambu-lab-eu-initial-catalog"
|
||||
BAMBU_PETG_BOOTSTRAP_KEY = "bambu-lab-eu-petg-basic-matte"
|
||||
BAMBU_PLA_PURE_BOOTSTRAP_KEY = "bambu-lab-eu-pla-pure"
|
||||
BAMBU_EU_UPDATE_BOOTSTRAP_KEY = "bambu-lab-eu-update-2026-11-16"
|
||||
SUNLU_BOOTSTRAP_KEY = "sunlu-de-initial-catalog"
|
||||
ESUN_BOOTSTRAP_KEY = "esun-eu-initial-catalog"
|
||||
JAYO_BOOTSTRAP_KEY = "jayo-eu-initial-catalog"
|
||||
@@ -38,6 +41,7 @@ class Command(BaseCommand):
|
||||
self.seed_catalog(
|
||||
options["verbosity"], BAMBU_PLA_PURE_BOOTSTRAP_KEY, "Bambu Lab", BAMBU_PLA_PURE_CATALOG
|
||||
)
|
||||
self.seed_bambu_update(options["verbosity"])
|
||||
self.seed_catalog(
|
||||
options["verbosity"], SUNLU_BOOTSTRAP_KEY, "SUNLU", SUNLU_CATALOG, sunlu_image_url
|
||||
)
|
||||
@@ -111,6 +115,37 @@ class Command(BaseCommand):
|
||||
)
|
||||
)
|
||||
|
||||
@transaction.atomic
|
||||
def seed_bambu_update(self, verbosity):
|
||||
_, should_import = CatalogBootstrap.objects.get_or_create(key=BAMBU_EU_UPDATE_BOOTSTRAP_KEY)
|
||||
if not should_import:
|
||||
return
|
||||
|
||||
manufacturer, _ = Manufacturer.objects.get_or_create(name="Bambu Lab")
|
||||
silk = Variant.objects.filter(
|
||||
product_type__manufacturer=manufacturer,
|
||||
product_type__name="PLA Silk Dual Color",
|
||||
spool_type=Variant.SpoolType.SPOOL,
|
||||
manufacturer_color_code="",
|
||||
)
|
||||
corrected = 0
|
||||
for color, code in PLA_SILK_DUAL_COLOR_CODES.items():
|
||||
corrected += silk.filter(color__name=color).update(manufacturer_color_code=code)
|
||||
|
||||
created = sum(
|
||||
self._import_catalog(
|
||||
manufacturer, catalog, diameter_mm=Decimal(diameter), match_color_code=True
|
||||
)
|
||||
for diameter, catalog in BAMBU_EU_UPDATE.items()
|
||||
)
|
||||
if verbosity:
|
||||
self.stdout.write(
|
||||
self.style.SUCCESS(
|
||||
f"Bambu-Lab-Katalog ergänzt: {created} Varianten und "
|
||||
f"{corrected} fehlende Artikelnummern."
|
||||
)
|
||||
)
|
||||
|
||||
@transaction.atomic
|
||||
def seed_catalog(
|
||||
self,
|
||||
@@ -127,14 +162,33 @@ class Command(BaseCommand):
|
||||
return
|
||||
|
||||
manufacturer, _ = Manufacturer.objects.get_or_create(name=manufacturer_name)
|
||||
created = self._import_catalog(manufacturer, catalog, image_url, diameter_mm=diameter_mm)
|
||||
if verbosity:
|
||||
self.stdout.write(
|
||||
self.style.SUCCESS(f"{manufacturer_name}-Katalog: {created} Varianten ergänzt.")
|
||||
)
|
||||
|
||||
def _import_catalog(
|
||||
self, manufacturer, catalog, image_url=None, *, diameter_mm, match_color_code=False
|
||||
):
|
||||
created = 0
|
||||
for name, catalog_variants in catalog.items():
|
||||
product, _ = ProductType.objects.get_or_create(manufacturer=manufacturer, name=name)
|
||||
for color_name, spool_type, sku, weight, swatch, image_path in catalog_variants:
|
||||
color, _ = Color.objects.get_or_create(name=color_name)
|
||||
color_id = None
|
||||
if match_color_code:
|
||||
# Reuse the other packaging's color even if an administrator renamed it.
|
||||
siblings = Variant.objects.filter(
|
||||
product_type=product, manufacturer_color_code=sku
|
||||
)
|
||||
if siblings.filter(spool_type=spool_type).exists():
|
||||
continue
|
||||
color_id = siblings.order_by("pk").values_list("color_id", flat=True).first()
|
||||
if color_id is None:
|
||||
color_id = Color.objects.get_or_create(name=color_name)[0].pk
|
||||
_, new = Variant.objects.get_or_create(
|
||||
product_type=product,
|
||||
color=color,
|
||||
color_id=color_id,
|
||||
spool_type=spool_type,
|
||||
defaults={
|
||||
"manufacturer_color_code": sku,
|
||||
@@ -145,10 +199,7 @@ class Command(BaseCommand):
|
||||
},
|
||||
)
|
||||
created += new
|
||||
if verbosity:
|
||||
self.stdout.write(
|
||||
self.style.SUCCESS(f"{manufacturer_name}-Katalog: {created} Varianten ergänzt.")
|
||||
)
|
||||
return created
|
||||
|
||||
|
||||
def sunlu_image_url(path):
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
from decimal import Decimal
|
||||
|
||||
from django.core.management import call_command, get_commands
|
||||
|
||||
from filament.bambu_catalog import BAMBU_LAB_PRODUCT_COUNT, BAMBU_LAB_VARIANT_COUNT
|
||||
from filament.bambu_color_names import PLA_SILK_DUAL_COLOR_CODES
|
||||
from filament.bambu_eu_catalog_update import BAMBU_EU_UPDATE
|
||||
from filament.forms import VariantSelectionForm
|
||||
from filament.management.commands.seed_catalog import (
|
||||
ANYCUBIC_BOOTSTRAP_KEY,
|
||||
BAMBU_EU_UPDATE_BOOTSTRAP_KEY,
|
||||
BAMBU_LAB_BOOTSTRAP_KEY,
|
||||
BAMBU_PETG_BOOTSTRAP_KEY,
|
||||
BAMBU_PLA_PURE_BOOTSTRAP_KEY,
|
||||
@@ -385,10 +390,10 @@ class CatalogTests(CatalogTestCase):
|
||||
call_command("seed_catalog", verbosity=0)
|
||||
self.assertEqual(
|
||||
ProductType.objects.filter(manufacturer__name="Bambu Lab").count(),
|
||||
BAMBU_LAB_PRODUCT_COUNT + 3,
|
||||
BAMBU_LAB_PRODUCT_COUNT + 6,
|
||||
)
|
||||
bambu_variants = Variant.objects.filter(product_type__manufacturer__name="Bambu Lab")
|
||||
self.assertEqual(bambu_variants.count(), BAMBU_LAB_VARIANT_COUNT + 52)
|
||||
self.assertEqual(bambu_variants.count(), BAMBU_LAB_VARIANT_COUNT + 95)
|
||||
self.assertFalse(
|
||||
bambu_variants.exclude(pk__in=(self.spool.pk, self.refill.pk, self.black_spool.pk))
|
||||
.filter(image_url="")
|
||||
@@ -454,6 +459,7 @@ class CatalogTests(CatalogTestCase):
|
||||
|
||||
def test_sunlu_imports_separately_into_existing_installations_and_preserves_edits(self):
|
||||
CatalogBootstrap.objects.create(key=BAMBU_LAB_BOOTSTRAP_KEY)
|
||||
CatalogBootstrap.objects.create(key=BAMBU_EU_UPDATE_BOOTSTRAP_KEY)
|
||||
call_command("seed_catalog", verbosity=0)
|
||||
sunlu = Manufacturer.objects.get(name="SUNLU")
|
||||
variants = Variant.objects.filter(product_type__manufacturer=sunlu)
|
||||
@@ -536,7 +542,12 @@ class CatalogTests(CatalogTestCase):
|
||||
CatalogBootstrap.objects.bulk_create(
|
||||
[
|
||||
CatalogBootstrap(key=key)
|
||||
for key in (BAMBU_LAB_BOOTSTRAP_KEY, SUNLU_BOOTSTRAP_KEY, ESUN_BOOTSTRAP_KEY)
|
||||
for key in (
|
||||
BAMBU_LAB_BOOTSTRAP_KEY,
|
||||
BAMBU_EU_UPDATE_BOOTSTRAP_KEY,
|
||||
SUNLU_BOOTSTRAP_KEY,
|
||||
ESUN_BOOTSTRAP_KEY,
|
||||
)
|
||||
]
|
||||
)
|
||||
product = ProductType.objects.create(manufacturer=self.maker, name="PETG Basic")
|
||||
@@ -602,6 +613,78 @@ class CatalogTests(CatalogTestCase):
|
||||
call_command("seed_catalog", verbosity=0)
|
||||
self.assertEqual(variants.count(), 9)
|
||||
|
||||
def test_bambu_update_adds_all_offers_and_backfills_silk_codes_in_place(self):
|
||||
marker = CatalogBootstrap.objects.create(key=BAMBU_EU_UPDATE_BOOTSTRAP_KEY)
|
||||
call_command("seed_catalog", verbosity=0)
|
||||
marker.delete()
|
||||
variants = Variant.objects.filter(product_type__manufacturer=self.maker)
|
||||
silk = variants.filter(product_type__name="PLA Silk Dual Color", manufacturer_color_code="")
|
||||
legacy_ids = dict(silk.values_list("color__name", "pk"))
|
||||
self.assertEqual(set(legacy_ids), set(PLA_SILK_DUAL_COLOR_CODES))
|
||||
velvet = silk.get(color__name="Velvet Eclipse (Black-Red)")
|
||||
velvet.is_active = False
|
||||
velvet.swatch = "#112233"
|
||||
velvet.save(update_fields=["is_active", "swatch"])
|
||||
stock_item = InventoryItem.objects.create(owner=self.alice, variant=velvet, quantity=2)
|
||||
old_petg = variants.get(manufacturer_color_code="33200", spool_type="refill")
|
||||
white = variants.get(
|
||||
product_type__name="PLA Silk+", manufacturer_color_code="13110", spool_type="spool"
|
||||
)
|
||||
white.color.name = "Mein Silk-Weiß"
|
||||
white.color.save(update_fields=["name"])
|
||||
before = set(variants.values_list("pk", flat=True))
|
||||
|
||||
call_command("seed_catalog", verbosity=0)
|
||||
self.assertEqual(variants.filter(pk__in=before).count(), len(before))
|
||||
created = variants.exclude(pk__in=before)
|
||||
expected = {
|
||||
(product, code, spool, weight, Decimal(diameter))
|
||||
for diameter, catalog in BAMBU_EU_UPDATE.items()
|
||||
for product, rows in catalog.items()
|
||||
for _, spool, code, weight, _, _ in rows
|
||||
}
|
||||
self.assertEqual(len(expected), 43)
|
||||
self.assertEqual(
|
||||
set(
|
||||
created.values_list(
|
||||
"product_type__name",
|
||||
"manufacturer_color_code",
|
||||
"spool_type",
|
||||
"net_weight_g",
|
||||
"diameter_mm",
|
||||
)
|
||||
),
|
||||
expected,
|
||||
)
|
||||
self.assertFalse(created.filter(image_url="").exists())
|
||||
for variant in created:
|
||||
variant.full_clean()
|
||||
for color, code in PLA_SILK_DUAL_COLOR_CODES.items():
|
||||
self.assertEqual(variants.get(pk=legacy_ids[color]).manufacturer_color_code, code)
|
||||
velvet.refresh_from_db()
|
||||
self.assertFalse(velvet.is_active)
|
||||
self.assertEqual(velvet.swatch, "#112233")
|
||||
self.assertEqual(InventoryItem.objects.get(pk=stock_item.pk).variant_id, velvet.pk)
|
||||
self.assertEqual(variants.get(pk=old_petg.pk).manufacturer_color_code, "33200")
|
||||
silk_refill = created.get(manufacturer_color_code="13110", spool_type="refill")
|
||||
self.assertEqual(silk_refill.color_id, white.color_id)
|
||||
|
||||
aurora = created.get(manufacturer_color_code="13909")
|
||||
self.assertEqual(aurora.color.name, "Aurora-Lila")
|
||||
self.assertEqual(aurora.swatch, "#7F3696,#006EC9")
|
||||
for path in ("/bestand/hinzufuegen/", "/bestellung/hinzufuegen/"):
|
||||
response = self.client.post(path, {"action": "lookup", "article_number": "13909"})
|
||||
self.assertEqual(response.context["form"].initial, self.selection(aurora))
|
||||
self.assertContains(response, "Aurora-Lila")
|
||||
aurora.is_active = False
|
||||
aurora.save(update_fields=["is_active"])
|
||||
spare = created.get(manufacturer_color_code="13906")
|
||||
spare.delete()
|
||||
call_command("seed_catalog", verbosity=0)
|
||||
aurora.refresh_from_db()
|
||||
self.assertFalse(aurora.is_active)
|
||||
self.assertFalse(variants.filter(manufacturer_color_code="13906").exists())
|
||||
|
||||
def test_jayo_and_anycubic_import_once_for_existing_installations(self):
|
||||
CatalogBootstrap.objects.bulk_create(
|
||||
CatalogBootstrap(key=key)
|
||||
@@ -609,6 +692,7 @@ class CatalogTests(CatalogTestCase):
|
||||
BAMBU_LAB_BOOTSTRAP_KEY,
|
||||
BAMBU_PETG_BOOTSTRAP_KEY,
|
||||
BAMBU_PLA_PURE_BOOTSTRAP_KEY,
|
||||
BAMBU_EU_UPDATE_BOOTSTRAP_KEY,
|
||||
SUNLU_BOOTSTRAP_KEY,
|
||||
ESUN_BOOTSTRAP_KEY,
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user