Display official German Bambu Lab color names
This commit is contained in:
1 parent
74326805de
commit
0c752fd7c6
10 files changed
+393
-17
No files matched your search
@@ -0,0 +1,260 @@
|
||||
# German color labels from Bambu Studio (2026-11-03).
|
||||
# https://github.com/bambulab/BambuStudio/blob/19843bf27197d55fb571e419aa58a29b60bab535/resources/profiles/BBL/filament/filaments_color_codes.json
|
||||
# Each code maps to the German label followed by recognized original names.
|
||||
BAMBU_STUDIO_COLOR_NAMES = {
|
||||
"10100": ("Jade-Weiß", "Jade White"),
|
||||
"10101": ("Schwarz", "Black"),
|
||||
"10102": ("Silber", "Silver"),
|
||||
"10103": ("Grau", "Gray"),
|
||||
"10104": ("Hellgrau", "Light Gray"),
|
||||
"10105": ("Dunkelgrau", "Dark Gray"),
|
||||
"10200": ("Rot", "Red"),
|
||||
"10201": ("Beige", "Beige"),
|
||||
"10202": ("Magenta", "Magenta"),
|
||||
"10203": ("Pink", "Pink"),
|
||||
"10204": ("Heißes Pink", "Hot Pink"),
|
||||
"10205": ("Kastanienrot", "Maroon Red"),
|
||||
"10300": ("Orange", "Orange"),
|
||||
"10301": ("Kürbis-Orange", "Pumpkin Orange"),
|
||||
"10400": ("Gelb", "Yellow"),
|
||||
"10401": ("Gold", "Gold"),
|
||||
"10402": ("Sonnenblumen-Gelb", "Sunflower Yellow"),
|
||||
"10501": ("Bambusgrün", "Bambu Green"),
|
||||
"10502": ("Mistelzweig-Grün", "Mistletoe Green"),
|
||||
"10503": ("Hellgrün", "Bright Green"),
|
||||
"10601": ("Blau", "Blue"),
|
||||
"10602": ("Blau-Grau", "Blue Gray", "Blue Grey"),
|
||||
"10603": ("Cyan", "Cyan"),
|
||||
"10604": ("Kobaltblau", "Cobalt Blue"),
|
||||
"10605": ("Türkis", "Turquoise"),
|
||||
"10700": ("Lila", "Purple"),
|
||||
"10701": ("Indigo-Violett", "Indigo Purple"),
|
||||
"10800": ("Braun", "Brown"),
|
||||
"10801": ("Bronze", "Bronze"),
|
||||
"10802": ("Kakaobraun", "Cocoa Brown"),
|
||||
"10900": ("Arktisches Flüstern", "Arctic Whisper"),
|
||||
"10901": ("Sonnenbrise", "Solar Breeze"),
|
||||
"10902": ("Meer und Wiese", "Ocean to Meadow"),
|
||||
"10903": ("Zitrus-Pink", "Pink Citrus"),
|
||||
"10904": ("Minze-Limette", "Mint Lime"),
|
||||
"10905": ("Blaubeere-Bubblegum", "Blueberry Bubblegum"),
|
||||
"10906": ("Leuchtende Abenddämmerung", "Dusk Glare"),
|
||||
"10907": ("Zuckerwatten-Wolke", "Cotton Candy Cloud"),
|
||||
"11100": ("Elfenbeinweiß", "Ivory White"),
|
||||
"11101": ("Kohlschwarz", "Charcoal", "Kohleschwarz"),
|
||||
"11102": ("Aschgrau", "Ash Gray", "Matte Ash Grey"),
|
||||
"11103": ("Knochenweiß", "Bone White", "Matte Bone White"),
|
||||
"11104": ("Nardo-Grau", "Nardo Gray", "Matte Nardo Gray"),
|
||||
"11200": ("Scharlachrot", "Scarlet Red"),
|
||||
"11201": ("Sakura-Pink", "Sakura Pink", "Matte Sakura Pink"),
|
||||
"11202": ("Dunkelrot", "Dark Red", "Matte Dark Red"),
|
||||
"11203": ("Terrakotta", "Terracotta", "Matte Terracotta"),
|
||||
"11204": ("Pflaume", "Plum", "Matte Plum"),
|
||||
"11300": ("Mandarine-Orange", "Mandarin Orange", "Matte Mandarin Orange"),
|
||||
"11400": ("Zitronengelb", "Lemon Yellow", "Matte Lemon Yellow"),
|
||||
"11401": ("Wüstenbraun", "Desert Tan", "Matte Desert Tan"),
|
||||
"11500": ("Grasgrün", "Grass Green", "Matte Grass Green"),
|
||||
"11501": ("Dunkelgrün", "Dark Green", "Matte Dark Green"),
|
||||
"11502": ("Apfelgrün", "Apple Green", "Matte Apple Green"),
|
||||
"11600": ("Marineblau", "Marine Blue", "Matte Marine Blue"),
|
||||
"11601": ("Eisblau", "Ice Blue"),
|
||||
"11602": ("Dunkelblau", "Dark Blue", "Matte Dark Blue"),
|
||||
"11603": ("Himmelblau", "Sky Blue", "Matte Sky Blue"),
|
||||
"11700": ("Flieder-Violett", "Lilac Purple", "Matte Lilac purple"),
|
||||
"11800": ("Milchkaffee-Braun", "Latte Brown", "Matte Latte Brown"),
|
||||
"11801": ("Dunkelbraun", "Dark Brown", "Matte Dark Brown"),
|
||||
"11802": ("Dunkel-Schokoladenbraun", "Dark Chocolate", "Matte Dark Chocolate"),
|
||||
"11803": ("Karamell", "Caramel", "Matte Caramel"),
|
||||
"12100": ("Weiß", "White"),
|
||||
"12101": ("Schwarz", "Black"),
|
||||
"12102": ("Grau", "Gray"),
|
||||
"12103": ("Silber", "Silver"),
|
||||
"12200": ("Zinnoberrot", "Vermilion Red"),
|
||||
"12300": ("Orange", "Orange"),
|
||||
"12400": ("Gelb", "Yellow"),
|
||||
"12500": ("Tannengrün", "Pine Green"),
|
||||
"12600": ("Hellblau", "Light Blue"),
|
||||
"12700": ("Lavendelblau", "Lavender Blue"),
|
||||
"13101": ("Glitzerndes Onyx-Schwarz", "Onyx Black Sparkle"),
|
||||
"13102": ("Glitzerndes Schiefergrau", "Slate Gray Sparkle"),
|
||||
"13103": ("Weißer Marmor", "White Marble"),
|
||||
"13104": ("Silber", "Silver"),
|
||||
"13105": ("Weiß", "White"),
|
||||
"13106": ("Weiße Eiche", "White Oak"),
|
||||
"13107": ("Schwarze Walnuss", "Black Walnut"),
|
||||
"13108": ("Titangrau", "Titan Gray"),
|
||||
"13109": ("Silber", "Silver"),
|
||||
"13110": ("Weiß", "White"),
|
||||
"13200": ("Glitzerndes Karminrot", "Crimson Red Sparkle"),
|
||||
"13201": ("Granitrot", "Red Granite"),
|
||||
"13202": ("Pink", "Pink"),
|
||||
"13203": ("Braun", "Brown"),
|
||||
"13204": ("Rosenholz", "Rosewood"),
|
||||
"13205": ("Candy-Rot", "Candy Red"),
|
||||
"13206": ("Gold-Rosa", "Rose Gold"),
|
||||
"13207": ("Pink", "Pink"),
|
||||
"13300": ("Kupfer", "Copper"),
|
||||
"13401": ("Gold", "Gold"),
|
||||
"13402": ("Klassisches Glitzer-Gold", "Classic Gold Sparkle"),
|
||||
"13403": ("Ockergelb", "Ochre Yellow"),
|
||||
"13404": ("Champagner", "Champagne"),
|
||||
"13405": ("Gold", "Gold"),
|
||||
"13501": ("Glitzerndes Alpengrün", "Alpine Green Sparkle"),
|
||||
"13502": ("Grün", "Green"),
|
||||
"13503": ("Grün", "Green"),
|
||||
"13504": ("Nebel", "Nebulae"),
|
||||
"13505": ("Klassische Birke", "Classic Birch"),
|
||||
"13506": ("Candy-Grün", "Candy Green"),
|
||||
"13507": ("Minze", "Mint"),
|
||||
"13601": ("Blau", "Blue"),
|
||||
"13602": ("Lila", "Purple"),
|
||||
"13603": ("Babyblau", "Baby Blue"),
|
||||
"13604": ("Blau", "Blue"),
|
||||
"13700": ("Glitzerndes Königslila", "Royal Purple Sparkle"),
|
||||
"13701": ("Lila", "Purple"),
|
||||
"13702": ("Lila", "Purple"),
|
||||
"13801": ("Lehmbraun", "Clay Brown"),
|
||||
"13901": ("Goldenes Rosa", "Gilded Rose", "Gilded Rose (Pink-Gold)"),
|
||||
"13902": ("Mitternachtsglanz", "Midnight Blaze", "Midnight Blaze (Blue-Red)"),
|
||||
"13903": ("Neon City", "Neon City", "Neon City (Blue-Magenta)"),
|
||||
"13904": ("Hawaii-Blau", "Blue Hawaii", "Blue Hawaii (Blue-Green)"),
|
||||
"13905": ("Dunkler Samt (Schwarz-Rot)", "Velvet Eclipse (Black-Red)"),
|
||||
"14100": ("Schwarz", "Black"),
|
||||
"14101": ("Lava-Grau", "Lava Gray"),
|
||||
"14102": ("Weiß", "White"),
|
||||
"14103": ("Schwarz", "Black"),
|
||||
"14104": ("Grau", "Gray"),
|
||||
"14200": ("Burgunderrot", "Burgundy Red"),
|
||||
"14500": ("Matcha-Grün", "Matcha Green"),
|
||||
"14600": ("Jeansblau", "Jeans Blue"),
|
||||
"14601": ("Königsblau", "Royal Blue"),
|
||||
"14700": ("Iris-Violett", "Iris Purple"),
|
||||
"15100": ("UV-Farbwechsel – Weiß nach Koralle", "UV Color Changing - White to Coral"),
|
||||
"15200": ("Leuchtend-Pink", "Glow Pink"),
|
||||
"15300": ("Leuchtend-Orange", "Glow Orange"),
|
||||
"15400": ("Leuchtend-Gelb", "Glow Yellow"),
|
||||
"15500": ("Leuchtend-Grün", "Glow Green"),
|
||||
"15600": ("Leuchtend-Blau", "Glow Blue"),
|
||||
"16101": ("Grau", "Gray"),
|
||||
"31100": ("Schwarz", "Black"),
|
||||
"31101": ("Titangrau", "Titan Gray"),
|
||||
"31200": ("Ziegelrot", "Brick Red"),
|
||||
"31500": ("Malachitgrün", "Malachite Green"),
|
||||
"31600": ("Indigo-Blau", "Indigo Blue"),
|
||||
"31700": ("Lila-Violett", "Violet Purple"),
|
||||
"32100": ("Durchsichtiges Grau", "Translucent Gray"),
|
||||
"32101": ("Klar", "Clear"),
|
||||
"32200": ("Durchsichtiges Pink", "Translucent Pink"),
|
||||
"32300": ("Durchsichtiges Orange", "Translucent Orange"),
|
||||
"32500": ("Durchsichtiges Olivgrün", "Translucent Olive"),
|
||||
"32501": ("Durchsichtiges Blaugrün", "Translucent Teal"),
|
||||
"32600": ("Durchsichtiges Hellblau", "Translucent Light Blue"),
|
||||
"32700": ("Durchsichtiges Lila", "Translucent Purple"),
|
||||
"32800": ("Durchsichtiges Braun", "Translucent Brown"),
|
||||
"33100": ("Weiß", "White"),
|
||||
"33101": ("Grau", "Gray"),
|
||||
"33102": ("Schwarz", "Black"),
|
||||
"33103": ("Dunkelgrau", "Dark Gray"),
|
||||
"33200": ("Rot", "Red"),
|
||||
"33300": ("Orange", "Orange"),
|
||||
"33400": ("Gelb", "Yellow"),
|
||||
"33401": ("Creme", "Cream"),
|
||||
"33500": ("Grün", "Green"),
|
||||
"33501": ("Limettengrün", "Lime Green"),
|
||||
"33502": ("Waldgrün", "Forest Green"),
|
||||
"33600": ("Blau", "Blue"),
|
||||
"33601": ("Blauer See", "Lake Blue"),
|
||||
"33801": ("Erdnussbraun", "Peanut Brown"),
|
||||
"40100": ("Weiß", "White", "ABS White"),
|
||||
"40101": ("Schwarz", "Black", "ABS Black"),
|
||||
"40102": ("Silber", "Silver", "ABS Silver"),
|
||||
"40200": ("Rot", "Red", "ABS Red"),
|
||||
"40300": ("Orange", "Orange", "ABS Orange"),
|
||||
"40400": ("Gelb", "Yellow"),
|
||||
"40401": ("Beige", "Beige"),
|
||||
"40402": ("Mandarinengelb", "Tangerine Yellow", "ABS Tangerine Yellow"),
|
||||
"40500": ("Bambusgrün", "Bambu Green", "ABS Bambu Green"),
|
||||
"40501": ("Minze", "Mint"),
|
||||
"40502": ("Olive", "Olive", "ABS Olive"),
|
||||
"40600": ("Blau", "Blue", "ABS Blue"),
|
||||
"40601": ("Azurblau", "Azure", "ABS Azure"),
|
||||
"40602": ("Marineblau", "Navy Blue", "ABS Navy Blue"),
|
||||
"40700": ("Lila", "Purple"),
|
||||
"40701": ("Lavendel", "Lavender"),
|
||||
"41100": ("Weiß", "White"),
|
||||
"41101": ("Schwarz", "Black"),
|
||||
"41102": ("Grau", "Gray"),
|
||||
"41200": ("Rot", "Red"),
|
||||
"41300": ("Orange", "Orange"),
|
||||
"41400": ("Gelb", "Yellow"),
|
||||
"41500": ("Grün", "Green"),
|
||||
"41600": ("Blau", "Blue"),
|
||||
"45100": ("Weiß", "White"),
|
||||
"45101": ("Schwarz", "Black"),
|
||||
"45102": ("Grau", "Gray"),
|
||||
"45200": ("Rot", "Red"),
|
||||
"45500": ("Grün", "Green"),
|
||||
"45600": ("Blau", "Blue"),
|
||||
"46100": ("Weiß", "White"),
|
||||
"46101": ("Schwarz", "Black"),
|
||||
"50100": ("Weiß", "White"),
|
||||
"50101": ("Schwarz", "Black"),
|
||||
"51100": ("Schwarz", "Black"),
|
||||
"51101": ("Grau", "Gray"),
|
||||
"51102": ("Weiß", "White"),
|
||||
"51200": ("Rot", "Red"),
|
||||
"51400": ("Gelb", "Yellow"),
|
||||
"51600": ("Blau", "Blue"),
|
||||
"53100": ("Weiß", "White"),
|
||||
"53101": ("Schwarz", "Black"),
|
||||
"53102": ("Grau", "Gray"),
|
||||
"53200": ("Rot", "Red"),
|
||||
"53400": ("Gelb", "Yellow"),
|
||||
"53500": ("Neongrün", "Neon Green"),
|
||||
"53600": ("Blau", "Blue"),
|
||||
"60100": ("Weiß", "White"),
|
||||
"60101": ("Schwarz", "Black"),
|
||||
"60102": ("Klares Schwarz", "Clear Black"),
|
||||
"60103": ("Durchsichtig", "Transparent"),
|
||||
"63100": ("Schwarz", "Black"),
|
||||
"63101": ("Weiß", "White"),
|
||||
"63102": ("Grau", "Gray"),
|
||||
"65102": ("Natur", "Nature"),
|
||||
"65103": ("Schwarz", "Black"),
|
||||
"65500": ("Grün", "Green"),
|
||||
"66100": ("Weiß", "White"),
|
||||
"66400": ("Klar", "Clear"),
|
||||
"70100": ("Schwarz", "Black"),
|
||||
"71100": ("Schwarz", "Black"),
|
||||
"72100": ("Schwarz", "Black"),
|
||||
"72102": ("Weiß", "White"),
|
||||
"72103": ("Grau", "Gray"),
|
||||
"72104": ("Schwarz", "Black"),
|
||||
"72200": ("Orange", "Orange"),
|
||||
"72400": ("Gelb", "Yellow"),
|
||||
"72500": ("Limette", "Lime"),
|
||||
"72600": ("Blau", "Blue"),
|
||||
"72800": ("Braun", "Brown"),
|
||||
"73100": ("Schwarz", "Black"),
|
||||
"76100": ("Schwarz", "Black"),
|
||||
}
|
||||
|
||||
# Older PLA Silk Dual Color entries were imported without a manufacturer color code.
|
||||
PLA_SILK_DUAL_COLOR_CODES = {
|
||||
"Blue Hawaii (Blue-Green)": "13904",
|
||||
"Gilded Rose (Pink-Gold)": "13901",
|
||||
"Midnight Blaze (Blue-Red)": "13902",
|
||||
"Neon City (Blue-Magenta)": "13903",
|
||||
"Velvet Eclipse (Black-Red)": "13905",
|
||||
}
|
||||
|
||||
|
||||
def bambu_color_label(product_name, color_code, color_name):
|
||||
code = color_code.strip()
|
||||
if not code and product_name == "PLA Silk Dual Color":
|
||||
code = PLA_SILK_DUAL_COLOR_CODES.get(color_name, "")
|
||||
if names := BAMBU_STUDIO_COLOR_NAMES.get(code):
|
||||
german, *original_names = names
|
||||
if color_name in original_names:
|
||||
return german
|
||||
return color_name
|
||||
+35
-9
@@ -1,5 +1,6 @@
|
||||
from django import forms
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.forms.models import ModelChoiceIterator
|
||||
|
||||
from .models import (
|
||||
Color,
|
||||
@@ -205,6 +206,23 @@ class SubtypeChoiceField(forms.ModelChoiceField):
|
||||
return obj.material_and_subtype[1]
|
||||
|
||||
|
||||
class ColorChoiceIterator(ModelChoiceIterator):
|
||||
def __iter__(self):
|
||||
if self.field.empty_label is not None:
|
||||
yield "", self.field.empty_label
|
||||
for color in sorted(
|
||||
self.queryset, key=lambda color: self.field.label_from_instance(color).casefold()
|
||||
):
|
||||
yield self.choice(color)
|
||||
|
||||
|
||||
class ColorChoiceField(forms.ModelChoiceField):
|
||||
iterator = ColorChoiceIterator
|
||||
|
||||
def label_from_instance(self, obj):
|
||||
return self.labels.get(obj.pk, obj.name)
|
||||
|
||||
|
||||
class ColorSelect(forms.Select):
|
||||
def create_option(self, name, value, label, selected, index, subindex=None, attrs=None):
|
||||
option = super().create_option(name, value, label, selected, index, subindex, attrs)
|
||||
@@ -221,7 +239,7 @@ class VariantSelectionForm(forms.Form):
|
||||
product_type = SubtypeChoiceField(
|
||||
label="Unterart", queryset=ProductType.objects.none(), empty_label="Unterart wählen"
|
||||
)
|
||||
color = forms.ModelChoiceField(
|
||||
color = ColorChoiceField(
|
||||
label="Farbe",
|
||||
queryset=Color.objects.none(),
|
||||
empty_label="Farbe wählen",
|
||||
@@ -277,14 +295,22 @@ class VariantSelectionForm(forms.Form):
|
||||
allowed_products = materials.get(selected_material, [])
|
||||
self.fields["product_type"].queryset = products.filter(pk__in=allowed_products)
|
||||
narrowed = active.filter(product_type_id=product, product_type_id__in=allowed_products)
|
||||
self.fields["color"].queryset = Color.objects.filter(variants__in=narrowed).distinct()
|
||||
# Prefer the spool's preview when the two packaging variants have different values.
|
||||
self.fields["color"].widget.swatches = dict(
|
||||
narrowed.exclude(swatch="")
|
||||
.order_by("spool_type", "pk")
|
||||
.values_list("color_id", "swatch")
|
||||
)
|
||||
spools = set(narrowed.filter(color_id=color).values_list("spool_type", flat=True))
|
||||
color_field = self.fields["color"]
|
||||
color_field.queryset = Color.objects.filter(variants__in=narrowed).distinct()
|
||||
color_field.labels = {}
|
||||
color_field.widget.swatches = {}
|
||||
spools = set()
|
||||
# A spool's label and preview take precedence when both packaging options supply them.
|
||||
for variant in narrowed.select_related("product_type__manufacturer", "color").order_by(
|
||||
"spool_type", "pk"
|
||||
):
|
||||
label = variant.color_label
|
||||
if label != variant.color.name:
|
||||
color_field.labels[variant.color_id] = label
|
||||
if variant.swatch:
|
||||
color_field.widget.swatches[variant.color_id] = variant.swatch
|
||||
if variant.color_id == color:
|
||||
spools.add(variant.spool_type)
|
||||
choices = (
|
||||
InventoryItem._meta.get_field("spool_type").choices
|
||||
if for_inventory
|
||||
|
||||
+13
-2
@@ -2,6 +2,8 @@ from django.conf import settings
|
||||
from django.core.validators import MaxValueValidator, MinValueValidator, RegexValidator
|
||||
from django.db import models
|
||||
|
||||
from .bambu_color_names import bambu_color_label
|
||||
|
||||
|
||||
class Manufacturer(models.Model):
|
||||
name = models.CharField("Hersteller", max_length=100, unique=True)
|
||||
@@ -140,13 +142,21 @@ class Variant(models.Model):
|
||||
def manufacturer(self):
|
||||
return self.product_type.manufacturer
|
||||
|
||||
@property
|
||||
def color_label(self):
|
||||
if self.manufacturer.name.casefold() == "bambu lab":
|
||||
return bambu_color_label(
|
||||
self.product_type.name, self.manufacturer_color_code, self.color.name
|
||||
)
|
||||
return self.color.name
|
||||
|
||||
def is_bambu_spool(self, spool_type):
|
||||
return (
|
||||
spool_type == self.SpoolType.SPOOL and self.manufacturer.name.casefold() == "bambu lab"
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.product_type} · {self.color} · {self.get_spool_type_display()}"
|
||||
return f"{self.product_type} · {self.color_label} · {self.get_spool_type_display()}"
|
||||
|
||||
|
||||
class QuantityPosition(models.Model):
|
||||
@@ -215,7 +225,8 @@ class InventoryItem(QuantityPosition):
|
||||
@property
|
||||
def stock_description(self):
|
||||
description = (
|
||||
f"{self.variant.product_type} · {self.variant.color} · {self.get_spool_type_display()}"
|
||||
f"{self.variant.product_type} · {self.variant.color_label} · "
|
||||
f"{self.get_spool_type_display()}"
|
||||
)
|
||||
return f"{description} (Bambu-Lab-Spule)" if self.bambu_spool else description
|
||||
|
||||
|
||||
@@ -228,6 +228,84 @@ class CatalogTests(CatalogTestCase):
|
||||
self.assertContains(response, "Kohleschwarz")
|
||||
self.assertFalse(response.context["form"].errors)
|
||||
|
||||
def test_bambu_color_labels_use_studio_names_without_renaming_colors(self):
|
||||
gradient = ProductType.objects.create(manufacturer=self.maker, name="PLA Basic Gradient")
|
||||
ocean = Color.objects.create(name="Ocean to Meadow")
|
||||
ocean_variant = Variant.objects.create(
|
||||
product_type=gradient,
|
||||
color=ocean,
|
||||
spool_type="spool",
|
||||
manufacturer_color_code="10902",
|
||||
swatch="#307FE2,#54FF9B",
|
||||
)
|
||||
custom = Color.objects.create(name="Mein Blau")
|
||||
custom_variant = Variant.objects.create(
|
||||
product_type=gradient, color=custom, spool_type="spool", manufacturer_color_code="10901"
|
||||
)
|
||||
solar = Variant.objects.create(
|
||||
product_type=gradient,
|
||||
color=Color.objects.create(name="Solar Breeze"),
|
||||
spool_type="spool",
|
||||
manufacturer_color_code="10901",
|
||||
)
|
||||
for path, model in (("bestand", InventoryItem), ("bestellung", OrderItem)):
|
||||
with self.subTest(path=path):
|
||||
url = f"/{path}/hinzufuegen/"
|
||||
response = self.client.post(url, {"action": "lookup", "article_number": "10902"})
|
||||
self.assertEqual(
|
||||
[
|
||||
label
|
||||
for value, label in response.context["form"].fields["color"].choices
|
||||
if value
|
||||
],
|
||||
["Meer und Wiese", "Mein Blau", "Sonnenbrise"],
|
||||
)
|
||||
self.assertContains(response, 'data-swatch="#307FE2,#54FF9B"')
|
||||
self.assertEqual(response.context["form"]["color"].value(), ocean.pk)
|
||||
self.assertRedirects(
|
||||
self.client.post(url, self.selection(ocean_variant)), f"/{path}/"
|
||||
)
|
||||
self.assertEqual(model.objects.get().variant_id, ocean_variant.pk)
|
||||
self.assertContains(self.client.get(f"/{path}/"), "Meer und Wiese")
|
||||
response = self.client.post(url, {"action": "lookup", "article_number": "10901"})
|
||||
self.assertEqual(set(response.context["matches"]), {solar, custom_variant})
|
||||
self.assertContains(response, "PLA Basic Gradient · Sonnenbrise")
|
||||
for query in ("Meer und Wiese", "Ocean to Meadow"):
|
||||
self.assertContains(self.client.get("/bestand/", {"q": query}), "Meer und Wiese")
|
||||
ocean.refresh_from_db()
|
||||
self.assertEqual(ocean.name, "Ocean to Meadow")
|
||||
|
||||
def test_bambu_color_labels_fall_back_when_translation_does_not_apply(self):
|
||||
blue = Color.objects.create(name="Ice Blue")
|
||||
translucent = ProductType.objects.create(manufacturer=self.maker, name="PLA Translucent")
|
||||
untranslated = Variant.objects.create(
|
||||
product_type=translucent,
|
||||
color=blue,
|
||||
spool_type="spool",
|
||||
manufacturer_color_code="13610",
|
||||
)
|
||||
other_maker = Manufacturer.objects.create(name="Anderer Hersteller")
|
||||
other_product = ProductType.objects.create(manufacturer=other_maker, name="PLA Matte")
|
||||
other = Variant.objects.create(
|
||||
product_type=other_product,
|
||||
color=blue,
|
||||
spool_type="spool",
|
||||
manufacturer_color_code="11601",
|
||||
)
|
||||
for variant in (untranslated, other):
|
||||
self.assertEqual(variant.color_label, "Ice Blue")
|
||||
form = VariantSelectionForm(selection=self.selection(variant))
|
||||
self.assertEqual(
|
||||
[label for value, label in form.fields["color"].choices if value], ["Ice Blue"]
|
||||
)
|
||||
dual_color = ProductType.objects.create(manufacturer=self.maker, name="PLA Silk Dual Color")
|
||||
silk = Variant.objects.create(
|
||||
product_type=dual_color,
|
||||
color=Color.objects.create(name="Neon City (Blue-Magenta)"),
|
||||
spool_type="spool",
|
||||
)
|
||||
self.assertEqual(silk.color_label, "Neon City")
|
||||
|
||||
def test_inactive_variants_stay_visible_in_existing_positions_but_cannot_be_added(self):
|
||||
stock = InventoryItem.objects.create(owner=self.alice, variant=self.spool, quantity=2)
|
||||
OrderItem.objects.create(owner=self.bob, variant=self.spool, quantity=1)
|
||||
|
||||
+2
-1
@@ -460,7 +460,7 @@ def inventory(request):
|
||||
sort_keys = {
|
||||
"manufacturer": lambda item: item.variant.manufacturer.name.casefold(),
|
||||
"product": lambda item: item.variant.product_type.name.casefold(),
|
||||
"color": lambda item: item.variant.color.name.casefold(),
|
||||
"color": lambda item: item.variant.color_label.casefold(),
|
||||
"spool": lambda item: item.get_spool_type_display().casefold(),
|
||||
"article": _stock_article_sort_key,
|
||||
"quantity": lambda item: item.quantity,
|
||||
@@ -510,6 +510,7 @@ def _stock_matches(item, terms):
|
||||
variant.manufacturer.name.casefold(),
|
||||
variant.product_type.name.casefold(),
|
||||
variant.color.name.casefold(),
|
||||
variant.color_label.casefold(),
|
||||
variant.manufacturer_color_code.casefold(),
|
||||
)
|
||||
return all(any(term in field for field in fields) for term in terms)
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
{% extends "base.html" %}{% block title %}Filamentkatalog · Fil-A-Management{% endblock %}{% block content %}<div class="page-heading"><div><p class="eyebrow">EINE AUSWAHL FÜR EUCH ALLE</p><h1>Der Filamentkatalog</h1><p class="muted">Eure aktiven Varianten. Vom Admin gepflegt, für alle verfügbar.</p></div>{% if user.is_superuser %}<a class="button secondary" href="/admin/filament/variant/">Katalog verwalten</a>{% endif %}</div>
|
||||
<section class="panel"><div class="panel-heading"><h2>Verfügbare Filamente</h2><span class="badge">{{ variants|length }} Varianten</span></div>{% if variants %}<div class="table-wrap"><table><thead><tr><th>Hersteller</th><th>Produktart</th><th>Farbe</th><th>Spulenausführung</th><th>Nettogewicht</th><th>Durchmesser</th></tr></thead><tbody>{% for variant in variants %}<tr><td>{{ variant.manufacturer }}</td><td>{{ variant.product_type.name }}</td><td><strong>{{ variant.color }}</strong>{% if variant.manufacturer_color_code %}<small>{{ variant.manufacturer_color_code }}</small>{% endif %}</td><td><span class="badge">{{ variant.get_spool_type_display }}</span></td><td>{% if variant.net_weight_g %}{{ variant.net_weight_g }} g{% else %}–{% endif %}</td><td>{% if variant.diameter_mm %}{{ variant.diameter_mm }} mm{% else %}–{% endif %}</td></tr>{% endfor %}</tbody></table></div>{% else %}<div class="empty"><h3>Der Katalog ist noch leer</h3><p>Dein Admin kann Filamentvarianten anlegen oder den Beispielkatalog laden.</p></div>{% endif %}</section><p class="hint">Vorhandene Bestands- und Bestellpositionen bleiben auch dann erhalten, wenn eine Variante deaktiviert wird.</p>{% endblock %}
|
||||
<section class="panel"><div class="panel-heading"><h2>Verfügbare Filamente</h2><span class="badge">{{ variants|length }} Varianten</span></div>{% if variants %}<div class="table-wrap"><table><thead><tr><th>Hersteller</th><th>Produktart</th><th>Farbe</th><th>Spulenausführung</th><th>Nettogewicht</th><th>Durchmesser</th></tr></thead><tbody>{% for variant in variants %}<tr><td>{{ variant.manufacturer }}</td><td>{{ variant.product_type.name }}</td><td><strong>{{ variant.color_label }}</strong>{% if variant.manufacturer_color_code %}<small>{{ variant.manufacturer_color_code }}</small>{% endif %}</td><td><span class="badge">{{ variant.get_spool_type_display }}</span></td><td>{% if variant.net_weight_g %}{{ variant.net_weight_g }} g{% else %}–{% endif %}</td><td>{% if variant.diameter_mm %}{{ variant.diameter_mm }} mm{% else %}–{% endif %}</td></tr>{% endfor %}</tbody></table></div>{% else %}<div class="empty"><h3>Der Katalog ist noch leer</h3><p>Dein Admin kann Filamentvarianten anlegen oder den Beispielkatalog laden.</p></div>{% endif %}</section><p class="hint">Vorhandene Bestands- und Bestellpositionen bleiben auch dann erhalten, wenn eine Variante deaktiviert wird.</p>{% endblock %}
|
||||
@@ -49,7 +49,7 @@
|
||||
<td>{{ item.variant.product_type }}</td>
|
||||
<td><div class="variant-preview">
|
||||
{% include "filament/variant_thumbnail.html" with variant=item.variant only %}
|
||||
<strong>{{ item.variant.color }}</strong>
|
||||
<strong>{{ item.variant.color_label }}</strong>
|
||||
</div></td>
|
||||
<td><span class="badge">In Benutzung</span></td>
|
||||
<td class="quantity">{{ item.quantity }}</td>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<td>{{ entry.owner.username }}</td>
|
||||
<td class="quantity">{{ entry.quantity }}</td>
|
||||
<td>{{ entry.variant.product_type.name }}<small>{{ entry.variant.manufacturer }}</small></td>
|
||||
<td><div class="variant-preview">{% include "filament/variant_thumbnail.html" with variant=entry.variant only %}<strong>{{ entry.variant.color }}</strong></div></td>
|
||||
<td><div class="variant-preview">{% include "filament/variant_thumbnail.html" with variant=entry.variant only %}<strong>{{ entry.variant.color_label }}</strong></div></td>
|
||||
<td class="article-number">{{ entry.variant.manufacturer_color_code|default:"–" }}</td>
|
||||
<td><span class="badge">{{ entry.variant.get_spool_type_display }}</span></td>
|
||||
<td><span class="badge">{{ entry.get_status_display }}</span></td>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<tr class="order-row order-row--{{ entry.status }}">
|
||||
<td class="quantity">{{ entry.quantity }}</td>
|
||||
<td>{{ entry.variant.product_type.name }}<small>{{ entry.variant.manufacturer }}</small></td>
|
||||
<td><div class="variant-preview">{% include "filament/variant_thumbnail.html" with variant=entry.variant only %}<strong>{{ entry.variant.color }}</strong></div></td>
|
||||
<td><div class="variant-preview">{% include "filament/variant_thumbnail.html" with variant=entry.variant only %}<strong>{{ entry.variant.color_label }}</strong></div></td>
|
||||
<td class="article-number">{{ entry.variant.manufacturer_color_code|default:"–" }}</td>
|
||||
<td><span class="badge">{{ entry.variant.get_spool_type_display }}</span>{% if not entry.variant.is_active %}<small class="warning">Deaktiviert · Katalogvariante</small>{% endif %}</td>
|
||||
<td>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
{% if forloop.first %}
|
||||
<td rowspan="{{ group|length }}">{{ item.variant.manufacturer }}</td>
|
||||
<td rowspan="{{ group|length }}">{{ item.variant.product_type.name }}</td>
|
||||
<th class="stock-color" scope="rowgroup" rowspan="{{ group|length }}"><div class="variant-preview">{% include "filament/variant_thumbnail.html" with variant=item.variant only %}<strong>{{ item.variant.color }}</strong></div></th>
|
||||
<th class="stock-color" scope="rowgroup" rowspan="{{ group|length }}"><div class="variant-preview">{% include "filament/variant_thumbnail.html" with variant=item.variant only %}<strong>{{ item.variant.color_label }}</strong></div></th>
|
||||
{% endif %}
|
||||
<td><span class="badge">{{ item.get_spool_type_display }}</span>{% if editable and item.bambu_spool %}<small class="stock-spool-brand">Bambu Lab</small>{% endif %}{% if not item.variant.is_active %}<small class="warning">Deaktiviert</small>{% endif %}</td>
|
||||
<td class="article-number">{{ item.variant.manufacturer_color_code|default:"–" }}</td>
|
||||
|
||||
Reference in new issue
Block a user