Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
...and Sales
Adam Janikbe0320505ba7
diff --git a/saleor/graphql/discount/mutations.py b/saleor/graphql/discount/mutations.pyindex 5408c38a56..48e40ec100 100644--- a/saleor/graphql/discount/mutations.py+++ b/saleor/graphql/discount/mutations.py@@ -59,7 +59,7 @@ class VoucherCreate(ModelMutation):return cleaned_input-class VoucherUpdate(ModelMutation):+class VoucherUpdate(VoucherCreate):class Arguments:id = graphene.ID(required=True, description='ID of a voucher to update.')@@ -71,18 +71,6 @@ class VoucherUpdate(ModelMutation):description = 'Updates a voucher.'model = models.Voucher- @classmethod- def user_is_allowed(cls, user, input):- return user.has_perm('discount.edit_voucher')-- @classmethod- def clean_input(cls, info, instance, input, errors):- cleaned_input = super().clean_input(info, instance, input, errors)- voucher_errors = validate_voucher(cleaned_input)- for err in voucher_errors:- cls.add_error(errors=errors, field=err[0], message=err[1])- return cleaned_input-class VoucherDelete(ModelDeleteMutation):class Arguments:@@ -100,7 +88,7 @@ class VoucherDelete(ModelDeleteMutation):class SaleInput(graphene.InputObjectType):name = graphene.String(description='Voucher name.')- type = graphene.String(description='Fixed or percentage.')+ type = DiscountValueTypeEnum(description='Fixed or percentage.')value = Decimal(description='Value of the voucher.')products = graphene.List(graphene.ID, description='Products related to the discount.')diff --git a/tests/api/test_discount.py b/tests/api/test_discount.pyindex ef2ca583f6..acb48202a9 100644--- a/tests/api/test_discount.py+++ b/tests/api/test_discount.py@@ -228,7 +228,7 @@ def test_voucher_delete_mutation(user_api_client, admin_api_client, voucher):def test_create_sale(user_api_client, admin_api_client):query = """mutation saleCreate(- $type: String, $name: String, $value: Decimal) {+ $type: DiscountValueTypeEnum, $name: String, $value: Decimal) {saleCreate(input: {name: $name, type: $type, value: $value}) {errors {field@@ -244,7 +244,7 @@ def test_create_sale(user_api_client, admin_api_client):"""variables = json.dumps({'name': 'test sale',- 'type': DiscountValueType.FIXED,+ 'type': DiscountValueTypeEnum.FIXED.name,'value': '10.12'})response = user_api_client.post(reverse('api'), {'query': query, 'variables': variables})@@ -262,7 +262,7 @@ def test_create_sale(user_api_client, admin_api_client):def test_update_sale(user_api_client, admin_api_client, sale):query = """- mutation saleUpdate($type: String, $id: ID!) {+ mutation saleUpdate($type: DiscountValueTypeEnum, $id: ID!) {saleUpdate(id: $id, input: {type: $type}) {errors {field@@ -279,7 +279,7 @@ def test_update_sale(user_api_client, admin_api_client, sale):sale.save()variables = json.dumps({'id': graphene.Node.to_global_id('Sale', sale.id),- 'type': DiscountValueType.PERCENTAGE})+ 'type': DiscountValueTypeEnum.PERCENTAGE.name})response = user_api_client.post(reverse('api'), {'query': query, 'variables': variables})