mirror of
https://github.com/pretix/pretix.git
synced 2026-03-09 13:32:27 +00:00
Make it optional to notify user on order change
This commit is contained in:
@@ -658,12 +658,13 @@ class OrderChangeManager:
|
||||
CancelOperation = namedtuple('CancelOperation', ('position',))
|
||||
AddOperation = namedtuple('AddOperation', ('item', 'variation', 'price', 'addon_to', 'subevent'))
|
||||
|
||||
def __init__(self, order: Order, user):
|
||||
def __init__(self, order: Order, user, notify=True):
|
||||
self.order = order
|
||||
self.user = user
|
||||
self._totaldiff = 0
|
||||
self._quotadiff = Counter()
|
||||
self._operations = []
|
||||
self.notify = notify
|
||||
self._invoice_dirty = False
|
||||
|
||||
def change_item(self, position: OrderPosition, item: Item, variation: Optional[ItemVariation]):
|
||||
@@ -971,7 +972,8 @@ class OrderChangeManager:
|
||||
self._reissue_invoice()
|
||||
self._clear_tickets_cache()
|
||||
self._check_paid_to_free()
|
||||
self._notify_user()
|
||||
if self.notify:
|
||||
self._notify_user()
|
||||
|
||||
def _clear_tickets_cache(self):
|
||||
CachedTicket.objects.filter(order_position__order=self.order).delete()
|
||||
|
||||
@@ -90,6 +90,14 @@ class OtherOperationsForm(forms.Form):
|
||||
'Use with care and only if you need to. Note that rounding differences might occur in this procedure.'
|
||||
)
|
||||
)
|
||||
notify = forms.BooleanField(
|
||||
label=_('Notify user'),
|
||||
required=False,
|
||||
initial=True,
|
||||
help_text=_(
|
||||
'Send an email to the customer notifying that their order has been changed.'
|
||||
)
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
kwargs.pop('order')
|
||||
|
||||
@@ -175,6 +175,7 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
{% bootstrap_field other_form.recalculate_taxes layout="control" %}
|
||||
{% bootstrap_field other_form.notify layout="control" %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -600,7 +600,12 @@ class OrderChange(OrderView):
|
||||
return True
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
ocm = OrderChangeManager(self.order, self.request.user)
|
||||
notify = self.other_form.cleaned_data['notify'] if self.other_form.is_valid() else True
|
||||
ocm = OrderChangeManager(
|
||||
self.order,
|
||||
user=self.request.user,
|
||||
notify=notify
|
||||
)
|
||||
form_valid = self._process_add(ocm) and self._process_change(ocm) and self._process_other(ocm)
|
||||
|
||||
if not form_valid:
|
||||
@@ -611,7 +616,10 @@ class OrderChange(OrderView):
|
||||
except OrderError as e:
|
||||
messages.error(self.request, str(e))
|
||||
else:
|
||||
messages.success(self.request, _('The order has been changed and the user has been notified.'))
|
||||
if notify:
|
||||
messages.success(self.request, _('The order has been changed and the user has been notified.'))
|
||||
else:
|
||||
messages.success(self.request, _('The order has been changed.'))
|
||||
return self._redirect_back()
|
||||
|
||||
return self.get(*args, **kwargs)
|
||||
|
||||
Reference in New Issue
Block a user