Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Improve doc
Adam Janik8de2590cc5da
diff --git a/saleor/graphql/order/mutations/draft_orders.py b/saleor/graphql/order/mutations/draft_orders.pyindex 226e4ab62f..acb8dd7958 100644--- a/saleor/graphql/order/mutations/draft_orders.py+++ b/saleor/graphql/order/mutations/draft_orders.py@@ -30,27 +30,25 @@ class AddressInput(graphene.InputObjectType):phone = graphene.String(description='Phone number.')-class LineInput(graphene.InputObjectType):+class OrderLineInput(graphene.InputObjectType):variant_id = graphene.ID(description='Product variant ID.')quantity = graphene.Int(- description='The number of products in the order.')+ description='Number of variant items ordered.')- class Meta:- description = 'Represents a permission object in a friendly form.'class DraftOrderInput(InputObjectType):billing_address = AddressInput(- description='Address associated with the payment.')+ description='Billing address of the customer.')user = graphene.ID(descripton='Customer associated with the draft order.')user_email = graphene.String(description='Email address of the customer.')discount = Decimal(description='Discount amount for the order.')lines = graphene.List(- LineInput,+ OrderLineInput,description="""Variant line input consisting of variant IDand quantity of products.""")shipping_address = AddressInput(- description='Address to where the order will be shipped.')+ description='Shipping address of the customer.')shipping_method = graphene.ID(description='ID of a selected shipping method.')voucher = graphene.ID(@@ -83,7 +81,7 @@ class DraftOrderCreate(ModelMutation):description='Fields required to create an order.')class Meta:- description = 'Creates a new variant for a product.'+ description = 'Creates a new draft order.'model = models.Order@classmethod@@ -229,15 +227,15 @@ class DraftOrderComplete(BaseMutation):order.status = OrderStatus.UNFULFILLEDif order.user:order.user_email = order.user.email- remove_shipping_address = Falseif not order.is_shipping_required():order.shipping_method_name = Noneorder.shipping_price = ZERO_TAXED_MONEYif order.shipping_address:- remove_shipping_address = True+ order.shipping_address.delete()order.save()- if remove_shipping_address:- order.shipping_address.delete()- msg = 'Order created from draft order'++ msg = pgettext_lazy(+ 'Dashboard message related to an order',+ 'Order created from draft order')order.history.create(content=msg, user=info.context.user)return DraftOrderComplete(order=order)diff --git a/saleor/graphql/order/mutations/fulfillments.py b/saleor/graphql/order/mutations/fulfillments.pyindex c6aa29ff2c..923a630ee5 100644--- a/saleor/graphql/order/mutations/fulfillments.py+++ b/saleor/graphql/order/mutations/fulfillments.py@@ -37,7 +37,8 @@ class FulfillmentCreateInput(graphene.InputObjectType):order = graphene.ID(description='ID of the order to be fulfilled.')tracking_number = graphene.String(description='Fulfillment tracking number')- notify_customer = graphene.Boolean(description='Is customer notified.')+ notify_customer = graphene.Boolean(+ description='If true, send an email notification to the customer.')lines = graphene.List(FulfillmentLineInput, description='Item line to be fulfilled.')@@ -45,7 +46,8 @@ class FulfillmentCreateInput(graphene.InputObjectType):class FulfillmentUpdateInput(graphene.InputObjectType):tracking_number = graphene.String(description='Fulfillment tracking number')- notify_customer = graphene.Boolean(description='Is customer notified.')+ notify_customer = graphene.Boolean(+ description='If true, send an email notification to the customer.')class FulfillmentCancelInput(graphene.InputObjectType):@@ -143,8 +145,13 @@ class FulfillmentCancel(BaseMutation):required=True,description='Fields required to cancel an fulfillment.')+ class Meta:+ description = """Cancels existing fulfillment+ and optionally restocks items."""++fulfillment = graphene.Field(- Fulfillment, description='released fulfillment.')+ Fulfillment, description='A canceled fulfillment.')@classmethod@permission_required('order.edit_order')diff --git a/saleor/graphql/order/mutations/orders.py b/saleor/graphql/order/mutations/orders.pyindex 3bf0e508a4..3a3a4963d2 100644--- a/saleor/graphql/order/mutations/orders.py+++ b/saleor/graphql/order/mutations/orders.py@@ -46,10 +46,10 @@ def clean_refund_payment(payment, amount):class OrderUpdateInput(graphene.InputObjectType):billing_address = AddressInput(- description='Address associated with the payment.')+ description='Billing address of the customer.')user_email = graphene.String(description='Email address of the customer.')shipping_address = AddressInput(- description='Address to where the order will be shipped.')+ description='Shipping address of the customer.')class OrderUpdate(DraftOrderUpdate):@@ -90,7 +90,8 @@ class OrderAddNote(ModelMutation):@classmethoddef save(cls, info, instance, cleaned_input):super().save(info, instance, cleaned_input)- msg = 'Added note'+ msg = pgettext_lazy(+ 'Dashboard message related to an order', 'Added note')instance.order.history.create(content=msg, user=info.context.user)@@ -102,6 +103,9 @@ class OrderCancel(BaseMutation):required=True,description='Determine if lines will be restocked or not.')+ class Meta:+ description = 'Cancel an order.'+order = graphene.Field(Order, description='Canceled order.')@@ -112,13 +116,14 @@ class OrderCancel(BaseMutation):cancel_order(order=order, restock=restock)if restock:restock_msg = npgettext_lazy(- 'Dashboard message',+ 'Dashboard message related to an order','Restocked %(quantity)d item','Restocked %(quantity)d items','quantity') % {'quantity': order.get_total_quantity()}order.history.create(content=restock_msg, user=info.context.user)else:- msg = pgettext_lazy('Dashboard message', 'Order canceled')+ msg = pgettext_lazy(+ 'Dashboard message related to an order', 'Order canceled')order.history.create(content=msg, user=info.context.user)return OrderCancel(order=order)@@ -128,8 +133,12 @@ class OrderMarkAsPaid(BaseMutation):id = graphene.ID(required=True, description='ID of the order to mark paid.')+ class Meta:+ description = 'Mark order as manually paid.'++order = graphene.Field(- Order, description='Mark order as manually paid.')+ Order, description='Order marked as paid.')@classmethod@permission_required('order.edit_order')@@ -151,7 +160,9 @@ class OrderMarkAsPaid(BaseMutation):variant=CustomPaymentChoices.MANUAL,status=PaymentStatus.CONFIRMED, order=order,defaults=defaults)- msg = 'Order manually marked as paid.'+ msg = pgettext_lazy(+ 'Dashboard message related to an order',+ 'Order manually marked as paid.')order.history.create(content=msg, user=info.context.user)return OrderMarkAsPaid(order=order)@@ -163,6 +174,9 @@ class OrderCapture(BaseMutation):amount = Decimal(required=True, description='Amount of money to capture.')+ class Meta:+ description = 'Capture an order.'+order = graphene.Field(Order, description='Captured order.')@@ -176,7 +190,9 @@ class OrderCapture(BaseMutation):if errors:return cls(errors=errors)- msg = 'Captured %(amount)s' % {'amount': amount}+ msg = pgettext_lazy(+ 'Dashboard message related to an order',+ 'Captured %(amount)s' % {'amount': amount})order.history.create(content=msg, user=info.context.user)return OrderCapture(order=order)@@ -186,8 +202,11 @@ class OrderRelease(BaseMutation):id = graphene.ID(required=True, description='ID of the order to release.')+ class Meta:+ description = 'Release an order.'+order = graphene.Field(- Order, description='released order.')+ Order, description='A released order.')@classmethod@permission_required('order.edit_order')@@ -198,7 +217,9 @@ class OrderRelease(BaseMutation):if errors:return cls(errors=errors)- msg = 'Released payment'+ msg = pgettext_lazy(+ 'Dashboard message related to an order',+ 'Released payment')order.history.create(content=msg, user=info.context.user)return OrderRelease(order=order)@@ -210,8 +231,11 @@ class OrderRefund(BaseMutation):amount = Decimal(required=True, description='Amount of money to refund.')+ class Meta:+ description = 'Refund an order.'+order = graphene.Field(- Order, description='released order.')+ Order, description='A refunded order.')@classmethod@permission_required('order.edit_order')@@ -222,6 +246,8 @@ class OrderRefund(BaseMutation):if errors:return cls(errors=errors)- msg = 'Refunded %(amount)s' % {'amount': amount}+ msg = pgettext_lazy(+ 'Dashboard message related to an order',+ 'Refunded %(amount)s' % {'amount': amount})order.history.create(content=msg, user=info.context.user)return OrderRefund(order=order)diff --git a/saleor/graphql/order/types.py b/saleor/graphql/order/types.pyindex 776098b0eb..c5587a9708 100644--- a/saleor/graphql/order/types.py+++ b/saleor/graphql/order/types.py@@ -18,7 +18,7 @@ class Order(CountableDjangoObjectType):description='User-friendly order status.')captured_amount = graphene.Field(Money, description='Amount captured by payment.')- total_prize = graphene.Field(+ total_price = graphene.Field(TaxedMoney, description='Total price of the order.')class Meta:diff --git a/tests/api/test_order.py b/tests/api/test_order.pyindex efd7e57f70..2eef1b38aa 100644--- a/tests/api/test_order.py+++ b/tests/api/test_order.py@@ -51,7 +51,7 @@ def test_order_query(admin_api_client, fulfilled_order):history {totalCount}- totalPrize {+ totalPrice {net {amount}@@ -118,7 +118,7 @@ def test_draft_order_create(variant_0 = variantquery = """mutation draftCreate(- $user: ID, $discount: Decimal, $lines: [LineInput],+ $user: ID, $discount: Decimal, $lines: [OrderLineInput],$shippingAddress: AddressInput, $shippingMethod: ID, $voucher: ID) {draftOrderCreate(input: {user: $user, discount: $discount,