Orders API: Consistently use "send_email" instead of "send_mail"

This commit is contained in:
Raphael Michel
2020-11-26 16:59:57 +01:00
parent 7ad46addee
commit d02e8b1dcf
4 changed files with 28 additions and 7 deletions
+2 -2
View File
@@ -940,9 +940,9 @@ Creating orders
during order generation and is not respected automatically when the order changes later.)
* ``force`` (optional). If set to ``true``, quotas will be ignored.
* ``send_mail`` (optional). If set to ``true``, the same emails will be sent as for a regular order, regardless of
* ``send_email`` (optional). If set to ``true``, the same emails will be sent as for a regular order, regardless of
whether these emails are enabled for certain sales channels. Defaults to
``false``.
``false``. Used to be ``send_mail`` before pretix 3.14.
If you want to use add-on products, you need to set the ``positionid`` fields of all positions manually
to incrementing integers starting with ``1``. Then, you can reference one of these
+3 -3
View File
@@ -682,7 +682,7 @@ class OrderCreateSerializer(I18nAwareModelSerializer):
consume_carts = serializers.ListField(child=serializers.CharField(), required=False)
force = serializers.BooleanField(default=False, required=False)
payment_date = serializers.DateTimeField(required=False, allow_null=True)
send_mail = serializers.BooleanField(default=False, required=False)
send_email = serializers.BooleanField(default=False, required=False)
simulate = serializers.BooleanField(default=False, required=False)
def __init__(self, *args, **kwargs):
@@ -693,7 +693,7 @@ class OrderCreateSerializer(I18nAwareModelSerializer):
model = Order
fields = ('code', 'status', 'testmode', 'email', 'locale', 'payment_provider', 'fees', 'comment', 'sales_channel',
'invoice_address', 'positions', 'checkin_attention', 'payment_info', 'payment_date', 'consume_carts',
'force', 'send_mail', 'simulate')
'force', 'send_email', 'simulate')
def validate_payment_provider(self, pp):
if pp is None:
@@ -786,7 +786,7 @@ class OrderCreateSerializer(I18nAwareModelSerializer):
payment_date = validated_data.pop('payment_date', now())
force = validated_data.pop('force', False)
simulate = validated_data.pop('simulate', False)
self._send_mail = validated_data.pop('send_mail', False)
self._send_mail = validated_data.pop('send_email', False)
if 'invoice_address' in validated_data:
iadata = validated_data.pop('invoice_address')
+2
View File
@@ -558,6 +558,8 @@ class OrderViewSet(viewsets.ModelViewSet):
)
def create(self, request, *args, **kwargs):
if 'send_mail' in request.data and 'send_email' not in request.data:
request.data['send_email'] = request.data['send_mail']
serializer = OrderCreateSerializer(data=request.data, context=self.get_serializer_context())
serializer.is_valid(raise_exception=True)
with transaction.atomic():
+21 -2
View File
@@ -3358,7 +3358,7 @@ def test_order_create_send_emails(token_client, organizer, event, item, quota, q
res = copy.deepcopy(ORDER_CREATE_PAYLOAD)
res['positions'][0]['item'] = item.pk
res['positions'][0]['answers'][0]['question'] = question.pk
res['send_mail'] = True
res['send_email'] = True
djmail.outbox = []
resp = token_client.post(
'/api/v1/organizers/{}/events/{}/orders/'.format(
@@ -3378,7 +3378,7 @@ def test_order_create_send_emails_free(token_client, organizer, event, item, quo
res['payment_provider'] = 'free'
del res['fees']
res['positions'][0]['answers'][0]['question'] = question.pk
res['send_mail'] = True
res['send_email'] = True
djmail.outbox = []
resp = token_client.post(
'/api/v1/organizers/{}/events/{}/orders/'.format(
@@ -3392,6 +3392,25 @@ def test_order_create_send_emails_free(token_client, organizer, event, item, quo
@pytest.mark.django_db
def test_order_create_send_emails_paid(token_client, organizer, event, item, quota, question):
res = copy.deepcopy(ORDER_CREATE_PAYLOAD)
res['positions'][0]['item'] = item.pk
res['positions'][0]['answers'][0]['question'] = question.pk
res['send_email'] = True
res['status'] = 'p'
djmail.outbox = []
resp = token_client.post(
'/api/v1/organizers/{}/events/{}/orders/'.format(
organizer.slug, event.slug
), format='json', data=res
)
assert resp.status_code == 201
assert len(djmail.outbox) == 2
assert djmail.outbox[0].subject == "Your order: {}".format(resp.data['code'])
assert djmail.outbox[1].subject == "Payment received for your order: {}".format(resp.data['code'])
@pytest.mark.django_db
def test_order_create_send_emails_legacy(token_client, organizer, event, item, quota, question):
res = copy.deepcopy(ORDER_CREATE_PAYLOAD)
res['positions'][0]['item'] = item.pk
res['positions'][0]['answers'][0]['question'] = question.pk