forked from CGM_Public/pretix_original
Sendmail: Allow to send only to (un)approved
This commit is contained in:
@@ -117,7 +117,9 @@ class MailForm(forms.Form):
|
||||
)
|
||||
self._set_field_placeholders('subject', ['event', 'order', 'position_or_address'])
|
||||
self._set_field_placeholders('message', ['event', 'order', 'position_or_address'])
|
||||
choices = list(Order.STATUS_CHOICE)
|
||||
choices = [(e, l) for e, l in Order.STATUS_CHOICE if e != 'n']
|
||||
choices.insert(0, ('na', _('payment pending (except unapproved)')))
|
||||
choices.insert(0, ('pa', _('approval pending')))
|
||||
if not event.settings.get('payment_term_expire_automatically', as_type=bool):
|
||||
choices.append(
|
||||
('overdue', _('pending with payment overdue'))
|
||||
@@ -130,7 +132,10 @@ class MailForm(forms.Form):
|
||||
choices=choices
|
||||
)
|
||||
if not self.initial.get('sendto'):
|
||||
self.initial['sendto'] = ['p', 'n']
|
||||
self.initial['sendto'] = ['p', 'na']
|
||||
elif 'n' in self.initial['sendto']:
|
||||
self.initial['sendto'].append('pa')
|
||||
self.initial['sendto'].append('na')
|
||||
|
||||
self.fields['items'].queryset = event.items.all()
|
||||
if not self.initial.get('items'):
|
||||
|
||||
@@ -84,6 +84,10 @@ class SenderView(EventPermissionRequiredMixin, FormView):
|
||||
statusq = Q(status__in=form.cleaned_data['sendto'])
|
||||
if 'overdue' in form.cleaned_data['sendto']:
|
||||
statusq |= Q(status=Order.STATUS_PENDING, expires__lt=now())
|
||||
if 'pa' in form.cleaned_data['sendto']:
|
||||
statusq |= Q(status=Order.STATUS_PENDING, require_approval=True)
|
||||
if 'na' in form.cleaned_data['sendto']:
|
||||
statusq |= Q(status=Order.STATUS_PENDING, require_approval=False)
|
||||
orders = qs.filter(statusq)
|
||||
|
||||
opq = OrderPosition.objects.filter(
|
||||
@@ -205,6 +209,8 @@ class EmailHistoryView(EventPermissionRequiredMixin, ListView):
|
||||
}
|
||||
status = dict(Order.STATUS_CHOICE)
|
||||
status['overdue'] = _('pending with payment overdue')
|
||||
status['na'] = _('payment pending (except unapproved)')
|
||||
status['pa'] = _('approval pending')
|
||||
status['r'] = status['c']
|
||||
for log in ctx['logs']:
|
||||
log.pdata = log.parsed_data
|
||||
|
||||
@@ -80,7 +80,7 @@ def test_sendmail_view(logged_in_client, sendmail_url, expected=200):
|
||||
def test_sendmail_simple_case(logged_in_client, sendmail_url, event, order, pos):
|
||||
djmail.outbox = []
|
||||
response = logged_in_client.post(sendmail_url,
|
||||
{'sendto': 'n',
|
||||
{'sendto': 'na',
|
||||
'recipients': 'orders',
|
||||
'items': pos.item_id,
|
||||
'subject_0': 'Test subject',
|
||||
@@ -122,7 +122,7 @@ def test_sendmail_email_not_sent_if_order_not_match(logged_in_client, sendmail_u
|
||||
def test_sendmail_preview(logged_in_client, sendmail_url, event, order, pos):
|
||||
djmail.outbox = []
|
||||
response = logged_in_client.post(sendmail_url,
|
||||
{'sendto': 'n',
|
||||
{'sendto': 'na',
|
||||
'recipients': 'orders',
|
||||
'items': pos.item_id,
|
||||
'subject_0': 'Test subject',
|
||||
@@ -140,7 +140,7 @@ def test_sendmail_preview(logged_in_client, sendmail_url, event, order, pos):
|
||||
def test_sendmail_invalid_data(logged_in_client, sendmail_url, event, order, pos):
|
||||
djmail.outbox = []
|
||||
response = logged_in_client.post(sendmail_url,
|
||||
{'sendto': 'n',
|
||||
{'sendto': 'na',
|
||||
'recipients': 'orders',
|
||||
'items': pos.item_id,
|
||||
'subject_0': 'Test subject',
|
||||
@@ -205,7 +205,7 @@ def test_sendmail_subevents(logged_in_client, sendmail_url, event, order, pos):
|
||||
|
||||
djmail.outbox = []
|
||||
response = logged_in_client.post(sendmail_url,
|
||||
{'sendto': 'n',
|
||||
{'sendto': 'na',
|
||||
'recipients': 'orders',
|
||||
'items': pos.item_id,
|
||||
'subject_0': 'Test subject',
|
||||
@@ -219,7 +219,7 @@ def test_sendmail_subevents(logged_in_client, sendmail_url, event, order, pos):
|
||||
|
||||
djmail.outbox = []
|
||||
response = logged_in_client.post(sendmail_url,
|
||||
{'sendto': 'n',
|
||||
{'sendto': 'na',
|
||||
'recipients': 'orders',
|
||||
'items': pos.item_id,
|
||||
'subject_0': 'Test subject',
|
||||
@@ -240,7 +240,7 @@ def test_sendmail_subevents(logged_in_client, sendmail_url, event, order, pos):
|
||||
def test_sendmail_placeholder(logged_in_client, sendmail_url, event, order, pos):
|
||||
djmail.outbox = []
|
||||
response = logged_in_client.post(sendmail_url,
|
||||
{'sendto': 'n',
|
||||
{'sendto': 'na',
|
||||
'recipients': 'orders',
|
||||
'items': pos.item_id,
|
||||
'subject_0': '{code} Test subject',
|
||||
@@ -264,7 +264,7 @@ def test_sendmail_attendee_mails(logged_in_client, sendmail_url, event, order, p
|
||||
|
||||
djmail.outbox = []
|
||||
response = logged_in_client.post(sendmail_url,
|
||||
{'sendto': 'n',
|
||||
{'sendto': 'na',
|
||||
'recipients': 'attendees',
|
||||
'items': pos.item_id,
|
||||
'subject_0': 'Test subject',
|
||||
@@ -288,7 +288,7 @@ def test_sendmail_both_mails(logged_in_client, sendmail_url, event, order, pos):
|
||||
|
||||
djmail.outbox = []
|
||||
response = logged_in_client.post(sendmail_url,
|
||||
{'sendto': 'n',
|
||||
{'sendto': 'na',
|
||||
'recipients': 'both',
|
||||
'items': pos.item_id,
|
||||
'subject_0': 'Test subject',
|
||||
@@ -315,7 +315,7 @@ def test_sendmail_both_but_same_address(logged_in_client, sendmail_url, event, o
|
||||
|
||||
djmail.outbox = []
|
||||
response = logged_in_client.post(sendmail_url,
|
||||
{'sendto': 'n',
|
||||
{'sendto': 'na',
|
||||
'recipients': 'both',
|
||||
'items': pos.item_id,
|
||||
'subject_0': 'Test subject',
|
||||
@@ -339,7 +339,7 @@ def test_sendmail_attendee_fallback(logged_in_client, sendmail_url, event, order
|
||||
|
||||
djmail.outbox = []
|
||||
response = logged_in_client.post(sendmail_url,
|
||||
{'sendto': 'n',
|
||||
{'sendto': 'na',
|
||||
'recipients': 'attendees',
|
||||
'items': pos.item_id,
|
||||
'subject_0': 'Test subject',
|
||||
@@ -368,7 +368,7 @@ def test_sendmail_attendee_product_filter(logged_in_client, sendmail_url, event,
|
||||
|
||||
djmail.outbox = []
|
||||
response = logged_in_client.post(sendmail_url,
|
||||
{'sendto': 'n',
|
||||
{'sendto': 'na',
|
||||
'recipients': 'attendees',
|
||||
'items': i2.pk,
|
||||
'subject_0': 'Test subject',
|
||||
@@ -396,7 +396,7 @@ def test_sendmail_attendee_checkin_filter(logged_in_client, sendmail_url, event,
|
||||
|
||||
djmail.outbox = []
|
||||
response = logged_in_client.post(sendmail_url,
|
||||
{'sendto': 'n',
|
||||
{'sendto': 'na',
|
||||
'recipients': 'attendees',
|
||||
'items': pos2.item_id,
|
||||
'filter_checkins': 'on',
|
||||
@@ -414,7 +414,7 @@ def test_sendmail_attendee_checkin_filter(logged_in_client, sendmail_url, event,
|
||||
|
||||
djmail.outbox = []
|
||||
response = logged_in_client.post(sendmail_url,
|
||||
{'sendto': 'n',
|
||||
{'sendto': 'na',
|
||||
'recipients': 'attendees',
|
||||
'items': pos2.item_id,
|
||||
'subject_0': 'Test subject',
|
||||
@@ -432,7 +432,7 @@ def test_sendmail_attendee_checkin_filter(logged_in_client, sendmail_url, event,
|
||||
|
||||
djmail.outbox = []
|
||||
response = logged_in_client.post(sendmail_url,
|
||||
{'sendto': 'n',
|
||||
{'sendto': 'na',
|
||||
'recipients': 'attendees',
|
||||
'items': pos2.item_id,
|
||||
'subject_0': 'Test subject',
|
||||
@@ -451,7 +451,7 @@ def test_sendmail_attendee_checkin_filter(logged_in_client, sendmail_url, event,
|
||||
# Test that filtering is ignored if filter_checkins is not set
|
||||
djmail.outbox = []
|
||||
response = logged_in_client.post(sendmail_url,
|
||||
{'sendto': 'n',
|
||||
{'sendto': 'na',
|
||||
'recipients': 'attendees',
|
||||
'items': pos2.item_id,
|
||||
'subject_0': 'Test subject',
|
||||
@@ -472,7 +472,7 @@ def test_sendmail_attendee_checkin_filter(logged_in_client, sendmail_url, event,
|
||||
# Test that filtering is ignored if filter_checkins is not set
|
||||
djmail.outbox = []
|
||||
response = logged_in_client.post(sendmail_url,
|
||||
{'sendto': 'n',
|
||||
{'sendto': 'na',
|
||||
'recipients': 'attendees',
|
||||
'items': pos2.item_id,
|
||||
'subject_0': 'Test subject',
|
||||
|
||||
Reference in New Issue
Block a user