Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix differences after merging with master
Marcin Gębaladdcf19c53e58
diff --git a/saleor/checkout/migrations/0015_merge_20180928_0658.py b/saleor/checkout/migrations/0015_merge_20180928_0658.pynew file mode 100644index 0000000000..1b64b5ecb4--- /dev/null+++ b/saleor/checkout/migrations/0015_merge_20180928_0658.py@@ -0,0 +1,14 @@+# Generated by Django 2.0.8 on 2018-09-28 11:58++from django.db import migrations+++class Migration(migrations.Migration):++ dependencies = [+ ('checkout', '0014_auto_20180921_0751'),+ ('checkout', '0011_auto_20180814_0216'),+ ]++ operations = [+ ]diff --git a/saleor/graphql/checkout/mutations.py b/saleor/graphql/checkout/mutations.pyindex 377d3d3866..687612cf69 100644--- a/saleor/graphql/checkout/mutations.py+++ b/saleor/graphql/checkout/mutations.py@@ -1,5 +1,6 @@import graphenefrom django.db import transaction+from django.utils.translation import pgettext_lazyfrom ...account.models import Addressfrom ...checkout import models@@ -10,7 +11,6 @@ from ...core import analyticsfrom ...core.exceptions import InsufficientStockfrom ..account.types import AddressInput, Userfrom ..core.mutations import BaseMutation, ModelMutation-from ..order.mutations.draft_orders import check_lines_quantityfrom ..order.types import Orderfrom ..product.types import ProductVariantfrom ..shipping.types import ShippingMethod@@ -18,6 +18,24 @@ from ..utils import get_nodesfrom .types import Checkout, CheckoutLine+def check_lines_quantity(variants, quantities):+ """Check if stock is sufficient for each line in the list of dicts.+ Return list of errors.+ """+ errors = []++ for variant, quantity in zip(variants, quantities):+ try:+ variant.check_quantity(quantity)+ except InsufficientStock as e:+ message = pgettext_lazy(+ 'Add line mutation error',+ 'Could not add item. Only %(remaining)d remaining in stock.' %+ {'remaining': e.item.quantity_available})+ errors.append((variant.name, message))+ return errors++class CheckoutLineInput(graphene.InputObjectType):quantity = graphene.Int(description='quantity')variant_id = graphene.ID(description='ID of product variant')