Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Update the documentation to include the customer events

NyanKiyoshidd7037af7ad2
diff --git a/docs/architecture/events.rst b/docs/architecture/events.rst
index 6e6a0b6122..22e4baf22d 100644
--- a/docs/architecture/events.rst
+++ b/docs/architecture/events.rst
@@ -6,6 +6,48 @@ Events
when certain actions are completed, such us creating the order,
cancelling fulfillment or completing a payment.
+
+Events Design
+-------------
+
+Each package representing an entity (order, account, etc.) that generate events
+define both a model and a ``events.py`` file containing a set of functions
+having ``_event`` for suffix.
+
+Those functions are taking care of any logic and required fields for
+creating given events.
+
+
+Creating Events
+---------------
+
+To send an event, simply do the following:
+
+.. code-block:: python
+
+ from saleor.order import events
+
+ # returns an OrderEvent
+ 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:
+
+.. code-block:: python
+
+ from saleor.order import events
+
+ events.email_sent_event(
+ order=order, user=user,
+ email_type=events.OrderEventsEmails.TRACKING_UPDATED)
+
+Notice how we are providing the email type.
+
+.. note::
+
+ The methods are using a ``model_action_event`` naming pattern.
+
+
Order Events
------------
@@ -51,6 +93,7 @@ Order Events
| ``other`` | ``OTHER`` | Status used during reimporting of the legacy events. | None. |
+----------------------------+----------------------------+---------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------+
+
Email Event Types
-----------------
@@ -69,6 +112,22 @@ Email Event Types
+------------------------------+----------------------+----------------------------------------------------------------------------------+
+Customer Related Events
+-----------------------
+
++-----------------------------+-----------------------------+------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------+
+| Code | GraphQL API value | Description | Additional Parameters (GraphQL) |
++-----------------------------+-----------------------------+------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------+
+| ``placed_order`` | ``PLACED_ORDER`` | The customer placed an order. | None. |
++-----------------------------+-----------------------------+------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------+
+| ``note_added_to_order`` | ``NOTE_ADDED_TO_ORDER`` | The customer added a note to one of their orders. | ``message`` (string) the message that the customer put as a note. |
++-----------------------------+-----------------------------+------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------+
+| ``digital_link_downloaded`` | ``DIGITAL_LINK_DOWNLOADED`` | The customer or another user (anonymous) downloaded an ordered digital good. | ``order_line`` (OrderLine) the fulfilled digital order line that the user downloaded. |
++-----------------------------+-----------------------------+------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------+
+| ``customer_deleted`` | ``CUSTOMER_DELETED`` | The staff user deleted one or many customers (anonymous). | ``count`` (int) the amount of customers deleted by the user. |
++-----------------------------+-----------------------------+------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------+
+
+
Events Design
-------------
diff --git a/saleor/account/__init__.py b/saleor/account/__init__.py
index 40492af34d..0d3911b0f2 100755
--- a/saleor/account/__init__.py
+++ b/saleor/account/__init__.py
@@ -16,7 +16,8 @@ class CustomerEvents:
(
PLACED_ORDER,
pgettext_lazy(
- "Event from a customer that placed an order", "An order was placed"
+ "Event from a customer that placed an order",
+ "An order was placed", # noqa
),
),
(