Skip to content

Commit

Permalink
Update the documentation to reflect the use of the black code style
Browse files Browse the repository at this point in the history
  • Loading branch information
NyanKiyoshi committed May 10, 2019
1 parent 06fa627 commit 2a20e5b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 26 deletions.
9 changes: 5 additions & 4 deletions docs/architecture/events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ To send an event, simply do the following:
from saleor.order import events
# returns an OrderEvent
events.note_added_event(
order=order, user=user, message='hello world!')
events.note_added_event(order=order, user=user, message="hello world!")
If now you want to send a 'sent email' event you would do the following:

Expand All @@ -100,8 +99,10 @@ If now you want to send a 'sent email' event you would do the following:
from saleor.order import events
events.email_sent_event(
order=order, user=user,
email_type=events.OrderEventsEmails.TRACKING_UPDATED)
order=order,
user=user,
email_type=events.OrderEventsEmails.TRACKING_UPDATED,
)
Notice how we are providing the email type.

Expand Down
2 changes: 1 addition & 1 deletion docs/architecture/money.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Money and TaxedMoney

In Saleor's codebase, money amounts exist either as `Money` or `TaxedMoney` instances.

`Money` is a type representing amount of money in specific currency: 100 USD is represented by `Money(100, 'USD')`.
`Money` is a type representing amount of money in specific currency: 100 USD is represented by `Money(100, "USD")`.
This type doesn't hold any additional information useful for commerce but, unlike `Decimal`, it implements safeguards and checks for calculations and comparisons of monetary values.

Money amounts are stored on model using `MoneyField` that provides its own safechecks on currency and precision of stored amount.
Expand Down
7 changes: 5 additions & 2 deletions docs/architecture/translations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,15 @@ We will use ``ProductTranslation`` to store our translated properties, it requi
class ProductTranslation(models.Model):
language_code = models.CharField(max_length=10)
product = models.ForeignKey(
Product, related_name='translations', on_delete=models.CASCADE)
Product,
related_name="translations",
on_delete=models.CASCADE,
)
name = models.CharField(max_length=128)
description = models.CharField(max_length=256)
class Meta:
unique_together = ('product', 'language_code')
unique_together = ("product", "language_code")
.. note:: Don't forget to set ``unique_together`` on the ``product`` and ``language_code``, there should be only one translation per product per language.

Expand Down
46 changes: 27 additions & 19 deletions docs/guides/payments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ Example
.. note::

All the below methods receive ``payment_information`` as a dataclass: ``PaymentData``.
Methods should return a response as a dataclass: ``GatewayResponse``.
All the below methods receive ``payment_information`` as a dataclass: ``PaymentData``.
Methods should return a response as a dataclass: ``GatewayResponse``.
The description of the given structures can be found below.


Expand All @@ -57,7 +57,8 @@ Example
def authorize(
payment_information: PaymentData,
connection_params: Dict) -> GatewayResponse:
connection_params: Dict,
) -> GatewayResponse:
# Handle connecting to the gateway and sending the auth request here
response = gateway.authorize(token=payment_information.token)
Expand Down Expand Up @@ -86,7 +87,8 @@ Example
def refund(
payment_information: PaymentData,
**connection_params: Dict) -> GatewayResponse:
**connection_params: Dict,
) -> GatewayResponse:
# Handle connecting to the gateway and sending the refund request here
response = gateway.refund(token=payment_information.token)
Expand Down Expand Up @@ -115,7 +117,8 @@ Example
def capture(
payment_information: PaymentData,
connection_params: Dict) -> GatewayResponse:
connection_params: Dict,
) -> GatewayResponse:
# Handle connecting to the gateway and sending the capture request here
response = gateway.capture(token=payment_information.token)
Expand Down Expand Up @@ -144,7 +147,8 @@ Example
def void(
payment_information: PaymentData,
connection_params: Dict) -> GatewayResponse:
connection_params: Dict,
) -> GatewayResponse:
# Handle connecting to the gateway and sending the void request here
response = gateway.void(token=payment_information.token)
Expand Down Expand Up @@ -173,7 +177,8 @@ Example
def charge(
payment_information: PaymentData,
connection_params: Dict) -> GatewayResponse:
connection_params: Dict,
) -> GatewayResponse:
# Handle connecting to the gateway and sending the charge request here
response = gateway.charge(
Expand Down Expand Up @@ -206,7 +211,8 @@ Example
def process_payment(
payment_information: PaymentData,
connection_params: Dict) -> GatewayResponse:
connection_params: Dict,
) -> GatewayResponse:
# Authorize, update the token, then capture
authorize_response = authorize(
Expand Down Expand Up @@ -348,7 +354,7 @@ Example
payment_method_nonce = forms.CharField()
def get_payment_token(self):
return self.cleaned_data['payment_method_nonce']
return self.cleaned_data["payment_method_nonce"]
Implement create_form(data, payment_information, connection_params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -365,7 +371,10 @@ Example
def create_form(data, payment_information, connection_params):
return BraintreePaymentForm(
data, payment_information, connection_params)
data,
payment_information,
connection_params,
)
Implement TEMPLATE_PATH
Expand All @@ -378,7 +387,7 @@ Example

.. code-block:: python
TEMPLATE_PATH = 'order/payment/braintree.html'
TEMPLATE_PATH = "order/payment/braintree.html"
Add template
^^^^^^^^^^^^
Expand All @@ -393,13 +402,13 @@ Adding new payment gateway to the settings
.. code-block:: python
PAYMENT_GATEWAYS = {
'braintree': {
'module': 'saleor.payment.gateways.braintree',
'connection_params': {
'sandbox_mode': get_bool_from_env('BRAINTREE_SANDBOX_MODE', True),
'merchant_id': os.environ.get('BRAINTREE_MERCHANT_ID'),
'public_key': os.environ.get('BRAINTREE_PUBLIC_KEY'),
'private_key': os.environ.get('BRAINTREE_PRIVATE_KEY')
"braintree": {
"module": "saleor.payment.gateways.braintree",
"connection_params": {
"sandbox_mode": get_bool_from_env("BRAINTREE_SANDBOX_MODE", True),
"merchant_id": os.environ.get("BRAINTREE_MERCHANT_ID"),
"public_key": os.environ.get("BRAINTREE_PUBLIC_KEY"),
"private_key": os.environ.get("BRAINTREE_PRIVATE_KEY"),
}
}
}
Expand Down Expand Up @@ -440,4 +449,3 @@ Tips
In such case, you might want to charge the customer 70 dollars, but due
to gateway misconfiguration, he will be charged 70 euros.
Such a situation should be handled, and adequate error should be thrown.

0 comments on commit 2a20e5b

Please sign in to comment.