Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Dashboard 1 attribute form no longer sets null/false values by default
NyanKiyoshi1be2c2fa309a
diff --git a/saleor/dashboard/product/forms.py b/saleor/dashboard/product/forms.pyindex ade311c9b1..542ce123aa 100644--- a/saleor/dashboard/product/forms.py+++ b/saleor/dashboard/product/forms.py@@ -527,7 +527,7 @@ class VariantImagesSelectForm(forms.Form):class AttributeForm(forms.ModelForm):class Meta:model = Attribute- exclude = ["input_type"]+ fields = ["name", "slug"]labels = {"name": pgettext_lazy("Product display name", "Display name"),"slug": pgettext_lazy("Product internal name", "Internal name"),diff --git a/tests/dashboard/test_product.py b/tests/dashboard/test_product.pyindex 8709f9beb7..bde8a75028 100644--- a/tests/dashboard/test_product.py+++ b/tests/dashboard/test_product.py@@ -878,7 +878,14 @@ def test_view_attribute_create(admin_client, color_attribute):response = admin_client.post(url, data, follow=True)assert response.status_code == 200- assert Attribute.objects.count() == 2, "An attribute should have been created"++ created_attribute = Attribute.objects.filter(slug="test").first()+ assert created_attribute is not None, "An attribute should have been created"++ assert created_attribute.name == "test"+ assert (+ created_attribute.visible_in_storefront is True+ ), "The default value should have been used"def test_view_attribute_create_not_valid(admin_client, color_attribute):@@ -902,6 +909,30 @@ def test_view_attribute_edit(color_attribute, admin_client):color_attribute.refresh_from_db()assert color_attribute.name == "new_name"assert color_attribute.slug == "new_slug"+ assert (+ color_attribute.visible_in_storefront is True+ ), "The default value should have been used"+++def test_view_attribute_edit_with_product_type(product, admin_client):+ old_attribute_count = Attribute.objects.count()+ product_attribute = (+ product.product_type.product_attributes.first()+ ) # type: Attribute+ url = reverse("dashboard:attribute-update", kwargs={"pk": product_attribute.pk})+ data = {"name": "new_name", "slug": "new_slug"}++ response = admin_client.post(url, data, follow=True)++ assert response.status_code == 200+ assert (+ Attribute.objects.count() == old_attribute_count+ ), "A new attribute shouldn't have been created"++ product_attribute.refresh_from_db()+ assert (+ product_attribute.product_types.count() == 1+ ), "Product type shouldn't have been unassigned"def test_view_attribute_delete(admin_client, color_attribute):