mirror of
https://github.com/pretix/pretix.git
synced 2026-10-10 20:44:41 +00:00
Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9639688c5a | ||
|
|
4119d04fba | ||
|
|
84858bc048 | ||
|
|
e8c091741b | ||
|
|
ebdfd21b0f | ||
|
|
ed0b3cab7f | ||
|
|
3dd8cc5862 | ||
|
|
23e9ca8f34 | ||
|
|
e19afd39fb |
Generated
+15
-15
@@ -194,16 +194,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint/config-array/node_modules/brace-expansion": {
|
||||
"version": "5.0.4",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.4.tgz",
|
||||
"integrity": "sha512-h+DEnpVvxmfVefa4jFbCf5HdH5YMDXRsmKflpf1pILZWRFlTbJpxeU55nJl4Smt5HQaGzg1o6RHFPJaOqnmBDg==",
|
||||
"version": "5.0.12",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz",
|
||||
"integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"balanced-match": "^4.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "18 || 20 || >=22"
|
||||
"node": "20 || >=22"
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint/config-array/node_modules/minimatch": {
|
||||
@@ -1339,16 +1339,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": {
|
||||
"version": "5.0.4",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.4.tgz",
|
||||
"integrity": "sha512-h+DEnpVvxmfVefa4jFbCf5HdH5YMDXRsmKflpf1pILZWRFlTbJpxeU55nJl4Smt5HQaGzg1o6RHFPJaOqnmBDg==",
|
||||
"version": "5.0.12",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz",
|
||||
"integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"balanced-match": "^4.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "18 || 20 || >=22"
|
||||
"node": "20 || >=22"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": {
|
||||
@@ -1697,9 +1697,9 @@
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/brace-expansion": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz",
|
||||
"integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==",
|
||||
"version": "2.1.7",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.7.tgz",
|
||||
"integrity": "sha512-uZbew1NqdmPDTMJ8ah1y+b+9QEJrfkXFk3RcTQw3X0jW/xRUvFKsg1CfQdSYGdTbXZWExtU3J3ccxtnfw1Fi0g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -2122,16 +2122,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/eslint/node_modules/brace-expansion": {
|
||||
"version": "5.0.4",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.4.tgz",
|
||||
"integrity": "sha512-h+DEnpVvxmfVefa4jFbCf5HdH5YMDXRsmKflpf1pILZWRFlTbJpxeU55nJl4Smt5HQaGzg1o6RHFPJaOqnmBDg==",
|
||||
"version": "5.0.12",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz",
|
||||
"integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"balanced-match": "^4.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "18 || 20 || >=22"
|
||||
"node": "20 || >=22"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint/node_modules/eslint-visitor-keys": {
|
||||
|
||||
@@ -19,4 +19,4 @@
|
||||
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
__version__ = "2026.8.0"
|
||||
__version__ = "2026.9.0.dev0"
|
||||
|
||||
@@ -92,9 +92,9 @@ from pretix.base.services.invoices import (
|
||||
regenerate_invoice, transmit_invoice,
|
||||
)
|
||||
from pretix.base.services.orders import (
|
||||
OrderChangeManager, OrderError, _order_placed_email,
|
||||
_order_placed_email_attendee, approve_order, cancel_order, deny_order,
|
||||
extend_order, mark_order_expired, mark_order_refunded, reactivate_order,
|
||||
OrderChangeManager, OrderError, _attendee_mail_send_helper,
|
||||
_order_placed_email, approve_order, cancel_order, deny_order, extend_order,
|
||||
mark_order_expired, mark_order_refunded, reactivate_order,
|
||||
)
|
||||
from pretix.base.services.pricing import get_price
|
||||
from pretix.base.services.tickets import generate
|
||||
@@ -805,17 +805,42 @@ class EventOrderViewSet(OrderViewSetMixin, viewsets.ModelViewSet):
|
||||
log_entry, invoice, [payment] if payment else [], is_free=free_flow
|
||||
)
|
||||
if email_attendees:
|
||||
for p in order.positions.all():
|
||||
if p.addon_to_id is None and p.attendee_email and p.attendee_email != order.email:
|
||||
_order_placed_email_attendee(request.event, order, p, email_attendees_template, subject_attendees_template,
|
||||
log_entry, is_free=free_flow)
|
||||
ev = request.event
|
||||
# todo re note: order_placed_email for attendees (formerly services/orders _order_placed_email_attendee)
|
||||
_attendee_mail_send_helper(
|
||||
event=ev,
|
||||
order=order,
|
||||
positions=order.positions.all(),
|
||||
template=email_attendees_template,
|
||||
subject=subject_attendees_template,
|
||||
log_entry_type=log_entry,
|
||||
attach_tickets=True,
|
||||
attach_ical=ev.settings.mail_attach_ical and (
|
||||
not ev.settings.mail_attach_ical_paid_only or
|
||||
free_flow or
|
||||
order.valid_if_pending
|
||||
),
|
||||
attach_other_files=[a for a in [
|
||||
ev.settings.get('mail_attachment_new_order', as_type=str, default='')[len('file://'):]
|
||||
] if a],
|
||||
)
|
||||
|
||||
if not free_flow and order.status == Order.STATUS_PAID and payment:
|
||||
payment._send_paid_mail(invoice, None, '')
|
||||
if self.request.event.settings.mail_send_order_paid_attendee:
|
||||
for p in order.positions.all():
|
||||
if p.addon_to_id is None and p.attendee_email and p.attendee_email != order.email:
|
||||
payment._send_paid_mail_attendee(p, None)
|
||||
ev = request.event
|
||||
# todo re note: paid_mail for attendees (formerly models/orders _send_paid_mail_attendee)
|
||||
_attendee_mail_send_helper(
|
||||
event=ev,
|
||||
order=order,
|
||||
positions=order.positions.all(),
|
||||
template=ev.settings.mail_text_order_paid_attendee,
|
||||
subject=ev.settings.mail_subject_order_paid_attendee,
|
||||
log_entry_type='pretix.event.order.email.order_paid',
|
||||
invoices=[],
|
||||
attach_tickets=True,
|
||||
attach_ical=ev.settings.mail_attach_ical
|
||||
)
|
||||
|
||||
headers = self.get_success_headers(serializer.data)
|
||||
return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)
|
||||
|
||||
@@ -71,8 +71,8 @@ class EmailTransmissionType(TransmissionType):
|
||||
|
||||
def transmission_info_to_form_data(self, transmission_info: dict) -> dict:
|
||||
return {
|
||||
"transmission_email_other": bool(transmission_info.get("transmission_email_address")),
|
||||
"transmission_email_address": transmission_info.get("transmission_email_address"),
|
||||
"transmission_email_other": bool((transmission_info or {}).get("transmission_email_address")),
|
||||
"transmission_email_address": (transmission_info or {}).get("transmission_email_address"),
|
||||
}
|
||||
|
||||
def form_data_to_transmission_info(self, form_data: dict) -> dict:
|
||||
|
||||
@@ -2021,9 +2021,23 @@ class OrderPayment(models.Model):
|
||||
if send_mail and self.order.sales_channel.identifier in self.order.event.settings.mail_sales_channel_placed_paid:
|
||||
self._send_paid_mail(invoice if transmit_invoice_mail else None, user, mail_text)
|
||||
if self.order.event.settings.mail_send_order_paid_attendee:
|
||||
for p in self.order.positions.all():
|
||||
if p.addon_to_id is None and p.attendee_email and p.attendee_email != self.order.email:
|
||||
self._send_paid_mail_attendee(p, user)
|
||||
# todo re note: paid_mail for attendees (formerly models/orders _send_paid_mail_attendee)
|
||||
from pretix.base.services.orders import (
|
||||
_attendee_mail_send_helper,
|
||||
)
|
||||
|
||||
_attendee_mail_send_helper(
|
||||
event=self.order.event,
|
||||
order=self.order,
|
||||
positions=self.order.positions.all(),
|
||||
template=self.order.event.settings.mail_text_order_paid_attendee,
|
||||
subject=self.order.event.settings.mail_subject_order_paid_attendee,
|
||||
log_entry_type='pretix.event.order.email.order_paid',
|
||||
user=user,
|
||||
invoices=[],
|
||||
attach_tickets=True,
|
||||
attach_ical=self.order.event.settings.mail_attach_ical,
|
||||
)
|
||||
|
||||
if invoice and not transmit_invoice_mail:
|
||||
transmit_invoice.apply_async(args=(self.order.event_id, invoice.pk, False))
|
||||
|
||||
@@ -39,7 +39,8 @@ from pretix.base.models import (
|
||||
from pretix.base.services.locking import LockTimeoutException
|
||||
from pretix.base.services.mail import mail
|
||||
from pretix.base.services.orders import (
|
||||
OrderChangeManager, OrderError, _cancel_order, _try_auto_refund,
|
||||
OrderChangeManager, OrderError, _attendee_mail_send_helper, _cancel_order,
|
||||
_try_auto_refund,
|
||||
)
|
||||
from pretix.base.services.tasks import ProfiledEventTask
|
||||
from pretix.base.services.tax import split_fee_for_taxes
|
||||
@@ -79,22 +80,38 @@ def _send_mail(order: Order, subject: LazyI18nString, message: LazyI18nString, s
|
||||
user,
|
||||
)
|
||||
|
||||
for p in positions:
|
||||
if subevent and p.subevent_id != subevent.id:
|
||||
continue
|
||||
# todo before pr ready: (aka note to myself)
|
||||
# check if we use a checkbox in the form here
|
||||
# (because before, we didn't check for it and maybe we don't want to here)
|
||||
# also: do we really want to inform attendees about the refund_amount
|
||||
# or do we need to because else the template does not work?
|
||||
_attendee_mail_send_helper(
|
||||
event=order.event,
|
||||
order=order,
|
||||
positions=positions,
|
||||
template=message,
|
||||
subject=subject,
|
||||
log_entry_type='pretix.event.order.email.event_canceled',
|
||||
user=user,
|
||||
subevent=subevent,
|
||||
)
|
||||
|
||||
if p.addon_to_id is None and p.attendee_email and p.attendee_email != order.email:
|
||||
email_context = get_email_context(event_or_subevent=p.subevent or order.event,
|
||||
event=order.event,
|
||||
refund_amount=refund_amount,
|
||||
position_or_address=p,
|
||||
order=order, position=p)
|
||||
order.send_mail(
|
||||
subject, message, email_context,
|
||||
'pretix.event.order.email.event_canceled',
|
||||
position=p,
|
||||
user=user
|
||||
)
|
||||
# for p in positions:
|
||||
# if subevent and p.subevent_id != subevent.id:
|
||||
# continue
|
||||
#
|
||||
# if p.addon_to_id is None and p.attendee_email and p.attendee_email != order.email:
|
||||
# email_context = get_email_context(event_or_subevent=p.subevent or order.event,
|
||||
# event=order.event,
|
||||
# refund_amount=refund_amount,
|
||||
# position_or_address=p,
|
||||
# order=order, position=p)
|
||||
# order.send_mail(
|
||||
# subject, message, email_context,
|
||||
# 'pretix.event.order.email.event_canceled',
|
||||
# position=p,
|
||||
# user=user
|
||||
# )
|
||||
|
||||
|
||||
@app.task(base=ProfiledEventTask, bind=True, max_retries=5, default_retry_delay=1, throws=(OrderError,))
|
||||
|
||||
@@ -114,6 +114,76 @@ from pretix.presale.productlist import prepare_item_list_for_shop
|
||||
from pretix.testutils.middleware import debugflags_var
|
||||
|
||||
|
||||
# todo before pr ready: (aka note to myself)
|
||||
# think about placing this helper function somewhere better
|
||||
# also: check those mail send functions, instead of replacing
|
||||
# maybe we still want to use them here instead of generic send_mail
|
||||
# and/or maybe we want to generalize this thing to also include order mails
|
||||
# (let's maybe not rewrite the whole mail logic?!)
|
||||
# but also, remember to write tests - a whole bunch of tests
|
||||
def _attendee_mail_send_helper(
|
||||
event: Event,
|
||||
order: Order,
|
||||
positions: list,
|
||||
template,
|
||||
subject,
|
||||
user,
|
||||
invoices: list = None,
|
||||
log_entry_type: str = 'pretix.event.order.email.sent',
|
||||
attach_tickets: bool = False,
|
||||
attach_ical: bool = False,
|
||||
attach_other_files: list = None,
|
||||
subevent: SubEvent = None,
|
||||
):
|
||||
parent_op = None
|
||||
sent_to_positions = set()
|
||||
for p in positions:
|
||||
if subevent and p.subevent_id != subevent.id:
|
||||
continue
|
||||
|
||||
if p.addon_to_id is None:
|
||||
# this op might have matching add-ons, so save for later
|
||||
parent_op = p
|
||||
elif not parent_op or p.addon_to_id != parent_op.id:
|
||||
# this op is an add-on, but not to the current parent_op
|
||||
# something got mixed up as add-ons should always come directly after their parent
|
||||
logger.warning(f"Add-ons are mixed up for position #{p.positionid} in order {order.full_code}")
|
||||
continue
|
||||
|
||||
if p.addon_to_id and (
|
||||
not p.attendee_email or p.attendee_email == parent_op.attendee_email
|
||||
):
|
||||
# if op is addon and either has no mail or the same as parent => send to parent
|
||||
p = parent_op
|
||||
|
||||
if p.pk in sent_to_positions:
|
||||
# this position already got an email
|
||||
continue
|
||||
|
||||
if not p.attendee_email or p.attendee_email == order.email:
|
||||
# no email or same as order
|
||||
continue
|
||||
|
||||
email_ctx = get_email_context(event=order.event, order=order, position=p)
|
||||
|
||||
p.send_mail(
|
||||
subject=subject,
|
||||
template=template,
|
||||
context=email_ctx,
|
||||
log_entry_type=log_entry_type,
|
||||
user=user if user else None,
|
||||
invoices=invoices,
|
||||
attach_tickets=attach_tickets,
|
||||
attach_ical=attach_ical,
|
||||
attach_other_files=attach_other_files,
|
||||
# possible, as of yet unused here, parameters:
|
||||
# headers: dict=None,
|
||||
# sender: str=None,
|
||||
# auth=None,
|
||||
)
|
||||
sent_to_positions.add(p.pk)
|
||||
|
||||
|
||||
class OrderError(Exception):
|
||||
def __init__(self, *args):
|
||||
msg = args[0]
|
||||
@@ -461,14 +531,21 @@ def approve_order(order, user=None, send_mail: bool=True, auth=None, force=False
|
||||
)
|
||||
|
||||
if email_attendees:
|
||||
for p in order.positions.all():
|
||||
if p.addon_to_id is None and p.attendee_email and p.attendee_email != order.email:
|
||||
email_attendee_context = get_email_context(event=order.event, order=order, position=p)
|
||||
p.send_mail(
|
||||
email_attendee_subject, email_attendee_template, email_attendee_context,
|
||||
'pretix.event.order.email.order_approved', user,
|
||||
attach_tickets=True,
|
||||
)
|
||||
_attendee_mail_send_helper(
|
||||
event=order.event,
|
||||
order=order,
|
||||
positions=order.positions.all(),
|
||||
template=email_attendee_template,
|
||||
subject=email_attendee_subject,
|
||||
log_entry_type='pretix.event.order.email.order_approved',
|
||||
user=user,
|
||||
attach_tickets=True,
|
||||
attach_ical=order.event.settings.mail_attach_ical and (
|
||||
not order.event.settings.mail_attach_ical_paid_only or
|
||||
order.total == Decimal('0.00') or
|
||||
order.valid_if_pending
|
||||
),
|
||||
)
|
||||
|
||||
return order.pk
|
||||
|
||||
@@ -1399,10 +1476,20 @@ def _perform_order(event: Event, payment_requests: List[dict], position_ids: Lis
|
||||
is_free=free_order_flow
|
||||
)
|
||||
if email_attendees:
|
||||
for p in order.positions.all():
|
||||
if p.addon_to_id is None and p.attendee_email and p.attendee_email != order.email:
|
||||
_order_placed_email_attendee(event, order, p, email_attendees_template, subject_attendees_template, log_entry,
|
||||
is_free=free_order_flow)
|
||||
# todo re note: order_placed_email for attendees (formerly services/orders _order_placed_email_attendee)
|
||||
_attendee_mail_send_helper(
|
||||
event=event,
|
||||
order=order,
|
||||
positions=order.positions.all(),
|
||||
template=email_attendees_template,
|
||||
subject=subject_attendees_template,
|
||||
log_entry_type=log_entry,
|
||||
attach_ical=event.settings.mail_attach_ical and (
|
||||
not event.settings.mail_attach_ical_paid_only or
|
||||
free_order_flow or
|
||||
order.valid_if_pending
|
||||
),
|
||||
)
|
||||
|
||||
if not any_payment_failed:
|
||||
for p in payment_objs:
|
||||
@@ -1601,6 +1688,7 @@ def send_download_reminders(sender, **kwargs):
|
||||
)
|
||||
|
||||
if event.settings.mail_send_download_reminder_attendee:
|
||||
send_to_positions = []
|
||||
for p in positions:
|
||||
if p.subevent_id:
|
||||
reminder_date = (p.subevent.date_from - timedelta(days=event.reminder_days)).replace(
|
||||
@@ -1608,15 +1696,22 @@ def send_download_reminders(sender, **kwargs):
|
||||
)
|
||||
if now() < reminder_date:
|
||||
continue
|
||||
if p.addon_to_id is None and p.attendee_email and p.attendee_email != o.email:
|
||||
email_template = event.settings.mail_text_download_reminder_attendee
|
||||
email_subject = event.settings.mail_subject_download_reminder_attendee
|
||||
email_context = get_email_context(event=event, order=o, position=p)
|
||||
o.send_mail(
|
||||
email_subject, email_template, email_context,
|
||||
'pretix.event.order.email.download_reminder_sent',
|
||||
attach_tickets=True, position=p
|
||||
)
|
||||
else:
|
||||
send_to_positions.append(p)
|
||||
# todo before pr ready (aka note to myself):
|
||||
# order's send_mail used before, check if there was a good reason to not
|
||||
# use postion's send_mail
|
||||
# if not, look for a way to not use double iteration over positions (see above)
|
||||
# otherwise: rewrite this without this helper function anyway
|
||||
_attendee_mail_send_helper(
|
||||
event=event,
|
||||
order=o,
|
||||
positions=send_to_positions,
|
||||
email_template=event.settings.mail_text_download_reminder_attendee,
|
||||
email_subject=event.settings.mail_subject_download_reminder_attendee,
|
||||
log_entry_type='pretix.event.order.email.download_reminder_sent',
|
||||
attach_tickets=True,
|
||||
)
|
||||
|
||||
|
||||
def notify_user_changed_order(order, user=None, auth=None, invoices=[]):
|
||||
|
||||
@@ -161,7 +161,12 @@ class OrderMailForm(BaseMailForm):
|
||||
),
|
||||
label=pgettext_lazy('sendmail_form', 'Restrict to products'),
|
||||
required=True,
|
||||
queryset=Item.objects.none()
|
||||
queryset=Item.objects.none(),
|
||||
help_text=pgettext_lazy(
|
||||
'sendmail_form',
|
||||
'There may be multiple mails sent out to the same mail address if one order contains multiple attendee '
|
||||
'products for it, if you restrict to products while also restricting mails to attendees only. '
|
||||
'This is intended, as every one of those get linked to their own separate order page restricted to only that product.')
|
||||
)
|
||||
filter_checkins = forms.BooleanField(
|
||||
label=_('Filter check-in status'),
|
||||
@@ -374,6 +379,11 @@ class RuleForm(FormPlaceholderMixin, I18nModelForm):
|
||||
del self.fields['subevent']
|
||||
|
||||
self.fields['limit_products'].queryset = Item.objects.filter(event=self.event)
|
||||
self.fields['limit_products'].help_text = pgettext_lazy(
|
||||
'sendmail_form',
|
||||
'There may be multiple mails sent out to the same mail address if one order contains multiple attendee '
|
||||
'products for it, if you restrict to products while also restricting mails to attendees only. '
|
||||
'This is intended, as every one of those get linked to their own separate order page restricted to only that product.')
|
||||
|
||||
self.fields['schedule_type'] = forms.ChoiceField(
|
||||
label=_('Type of schedule time'),
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
import logging
|
||||
from datetime import datetime, time, timedelta
|
||||
|
||||
from dateutil.tz import datetime_exists
|
||||
@@ -39,6 +40,8 @@ from pretix.base.models import (
|
||||
)
|
||||
from pretix.base.models.base import LoggingMixin
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ScheduledMail(models.Model):
|
||||
STATE_SCHEDULED = 'scheduled'
|
||||
@@ -115,7 +118,7 @@ class ScheduledMail(models.Model):
|
||||
|
||||
filter_orders_by_op = False
|
||||
op_qs = OrderPosition.objects.filter(
|
||||
order__event=self.event,
|
||||
order__event=e,
|
||||
canceled=False,
|
||||
)
|
||||
|
||||
@@ -167,14 +170,58 @@ class ScheduledMail(models.Model):
|
||||
for o in orders:
|
||||
with language(o.locale, e.settings.region):
|
||||
positions = list(o.positions.all())
|
||||
o_sent = False
|
||||
send_to_order = send_to_orders
|
||||
|
||||
try:
|
||||
ia = o.invoice_address
|
||||
except InvoiceAddress.DoesNotExist:
|
||||
ia = InvoiceAddress(order=o)
|
||||
|
||||
if send_to_orders and o.email:
|
||||
if send_to_attendees:
|
||||
parent_op = None
|
||||
sent_to_positions = set()
|
||||
for p in positions:
|
||||
if p.addon_to_id is None:
|
||||
# this op might have matching add-ons, so save for later
|
||||
parent_op = p
|
||||
elif not parent_op or p.addon_to_id != parent_op.id:
|
||||
# this op is an add-on, but not to the current parent_op
|
||||
# something got mixed up as add-ons should always come directly after their parent
|
||||
logger.warning(f"Add-ons are mixed up for position #{p.positionid} in order {o.full_code}")
|
||||
continue
|
||||
|
||||
if p.id not in position_ids:
|
||||
# not a matching op, just there for parent_op
|
||||
continue
|
||||
|
||||
if p.addon_to_id and (
|
||||
not p.attendee_email or p.attendee_email == parent_op.attendee_email
|
||||
):
|
||||
# if op is addon and either has no mail or the same as parent => send to parent
|
||||
p = parent_op
|
||||
|
||||
if p.pk in sent_to_positions:
|
||||
# this position already got an email
|
||||
continue
|
||||
|
||||
if not p.attendee_email or p.attendee_email == o.email:
|
||||
# no email or same as order => send to order
|
||||
send_to_order = True
|
||||
continue
|
||||
|
||||
email_ctx = get_email_context(
|
||||
event=e,
|
||||
order=o,
|
||||
invoice_address=ia,
|
||||
position=p,
|
||||
event_or_subevent=self.subevent or e,
|
||||
)
|
||||
p.send_mail(self.rule.subject, self.rule.template, email_ctx,
|
||||
attach_ical=self.rule.attach_ical,
|
||||
log_entry_type='pretix.plugins.sendmail.rule.order.position.email.sent')
|
||||
sent_to_positions.add(p.pk)
|
||||
|
||||
if send_to_order and o.email:
|
||||
email_ctx = get_email_context(
|
||||
event=e,
|
||||
order=o,
|
||||
@@ -184,38 +231,6 @@ class ScheduledMail(models.Model):
|
||||
o.send_mail(self.rule.subject, self.rule.template, email_ctx,
|
||||
attach_ical=self.rule.attach_ical,
|
||||
log_entry_type='pretix.plugins.sendmail.rule.order.email.sent')
|
||||
o_sent = True
|
||||
|
||||
if send_to_attendees:
|
||||
if not self.rule.all_products:
|
||||
positions = [p for p in positions if p.item_id in limit_products]
|
||||
if self.subevent_id:
|
||||
positions = [p for p in positions if p.subevent_id == self.subevent_id]
|
||||
|
||||
for p in positions:
|
||||
if p.id in position_ids:
|
||||
if p.attendee_email and (p.attendee_email != o.email or not o_sent):
|
||||
email_ctx = get_email_context(
|
||||
event=e,
|
||||
order=o,
|
||||
invoice_address=ia,
|
||||
position=p,
|
||||
event_or_subevent=self.subevent or e,
|
||||
)
|
||||
p.send_mail(self.rule.subject, self.rule.template, email_ctx,
|
||||
attach_ical=self.rule.attach_ical,
|
||||
log_entry_type='pretix.plugins.sendmail.rule.order.position.email.sent')
|
||||
elif not o_sent and o.email:
|
||||
email_ctx = get_email_context(
|
||||
event=e,
|
||||
order=o,
|
||||
invoice_address=ia,
|
||||
event_or_subevent=self.subevent or e,
|
||||
)
|
||||
o.send_mail(self.rule.subject, self.rule.template, email_ctx,
|
||||
attach_ical=self.rule.attach_ical,
|
||||
log_entry_type='pretix.plugins.sendmail.rule.order.email.sent')
|
||||
o_sent = True
|
||||
|
||||
self.last_successful_order_id = o.pk
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
# Unless required by applicable law or agreed to in writing, software distributed under the Apache License 2.0 is
|
||||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations under the License.
|
||||
import logging
|
||||
from datetime import datetime
|
||||
|
||||
from django.db.models import Exists, OuterRef, Q
|
||||
@@ -43,6 +44,8 @@ from pretix.base.services.mail import mail
|
||||
from pretix.base.services.tasks import ProfiledEventTask
|
||||
from pretix.celery_app import app
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _chunks(lst, n):
|
||||
"""
|
||||
@@ -70,6 +73,8 @@ def send_mails_to_orders(event: Event, user: int, subject: dict, message: dict,
|
||||
except InvoiceAddress.DoesNotExist:
|
||||
ia = InvoiceAddress(order=o)
|
||||
|
||||
parent_op = None
|
||||
sent_to_positions = set()
|
||||
if recipients in ('both', 'attendees'):
|
||||
for p in o.positions.annotate(
|
||||
any_checkins=Exists(
|
||||
@@ -85,10 +90,16 @@ def send_mails_to_orders(event: Event, user: int, subject: dict, message: dict,
|
||||
)
|
||||
),
|
||||
).prefetch_related('addons', 'subevent'):
|
||||
if p.addon_to_id is not None:
|
||||
|
||||
if p.addon_to_id is None:
|
||||
parent_op = p
|
||||
elif not parent_op or p.addon_to_id != parent_op.id:
|
||||
# this op is an add-on, but not to the current parent_op
|
||||
# something got mixed up as add-ons should always come directly after their parent
|
||||
logger.warning(f"Add-ons are mixed up for position #{p.positionid} in order {o.full_code}")
|
||||
continue
|
||||
|
||||
if p.item_id not in items and not any(a.item_id in items for a in p.addons.all()):
|
||||
if p.item_id not in items:
|
||||
continue
|
||||
|
||||
if filter_checkins:
|
||||
@@ -99,13 +110,11 @@ def send_mails_to_orders(event: Event, user: int, subject: dict, message: dict,
|
||||
if not allowed:
|
||||
continue
|
||||
|
||||
if not p.attendee_email:
|
||||
if recipients == 'attendees':
|
||||
send_to_order = True
|
||||
continue
|
||||
|
||||
if p.attendee_email == o.email and send_to_order:
|
||||
continue
|
||||
if p.addon_to_id and (
|
||||
not p.attendee_email or p.attendee_email == parent_op.attendee_email
|
||||
):
|
||||
# if op is addon and either has no mail or the same as parent => send to parent
|
||||
p = parent_op
|
||||
|
||||
if subevent and p.subevent_id != subevent:
|
||||
continue
|
||||
@@ -116,6 +125,18 @@ def send_mails_to_orders(event: Event, user: int, subject: dict, message: dict,
|
||||
if subevents_to and p.subevent.date_from >= subevents_to:
|
||||
continue
|
||||
|
||||
if not p.attendee_email:
|
||||
send_to_order = True
|
||||
continue
|
||||
|
||||
if p.pk in sent_to_positions:
|
||||
# this position already got an email
|
||||
continue
|
||||
|
||||
if p.attendee_email == o.email:
|
||||
send_to_order = True
|
||||
continue
|
||||
|
||||
with language(o.locale, event.settings.region):
|
||||
email_context = get_email_context(event=event, order=o, invoice_address=ia, position=p)
|
||||
outgoing_mail = mail(
|
||||
@@ -137,6 +158,7 @@ def send_mails_to_orders(event: Event, user: int, subject: dict, message: dict,
|
||||
user=user,
|
||||
data=outgoing_mail.log_data(),
|
||||
)
|
||||
sent_to_positions.add(p.pk)
|
||||
|
||||
if send_to_order and o.email:
|
||||
with language(o.locale, event.settings.region):
|
||||
|
||||
@@ -183,7 +183,6 @@ class OrderPositionDetailMixin(NoSearchIndexViewMixin):
|
||||
def position(self):
|
||||
qs = OrderPosition.objects.filter(
|
||||
order__event=self.request.event,
|
||||
addon_to__isnull=True,
|
||||
order__code=self.kwargs['order'],
|
||||
positionid=self.kwargs['position']
|
||||
).select_related('order', 'order__event')
|
||||
|
||||
@@ -117,6 +117,16 @@ input[type=number]::-webkit-outer-spin-button {
|
||||
border: transparent;
|
||||
}
|
||||
|
||||
.btn.disabled, .btn[disabled], fieldset[disabled] .btn {
|
||||
box-shadow: 0px 0px 0px 1px #ccc inset, inset 0 1px 3px 0 #d9d9d9;
|
||||
background: #eee;
|
||||
opacity: 0.7;
|
||||
}
|
||||
.btn-link.disabled, .btn-link[disabled], fieldset[disabled] .btn-link {
|
||||
box-shadow: none;
|
||||
background: none;
|
||||
}
|
||||
|
||||
.btn-group-flex { display: flex; }
|
||||
.btn-group-flex > .btn { flex: 1; }
|
||||
|
||||
|
||||
@@ -556,8 +556,6 @@ var editor = {
|
||||
editor.$fcv.get(0).height = editor.pdf_viewport.height
|
||||
editor.fabric = new fabric.Canvas('fabric-canvas')
|
||||
|
||||
editor.fabric.on('object:modified', editor._create_savepoint)
|
||||
editor.fabric.on('object:added', editor._create_savepoint)
|
||||
editor.fabric.on('selection:cleared', editor._update_toolbox)
|
||||
editor.fabric.on('selection:created', editor._update_toolbox)
|
||||
editor.fabric.on('selection:updated', editor._update_toolbox)
|
||||
@@ -590,6 +588,12 @@ var editor = {
|
||||
if (editor._window_loaded) {
|
||||
editor._ready()
|
||||
}
|
||||
|
||||
editor.fabric.on('object:modified', editor._create_savepoint)
|
||||
editor.fabric.on('object:added', editor._create_savepoint)
|
||||
editor.fabric.on('object:added', function(e) {
|
||||
editor.fabric.setActiveObject(e.target);
|
||||
})
|
||||
},
|
||||
|
||||
_window_load_event: function () {
|
||||
@@ -956,7 +960,6 @@ var editor = {
|
||||
mtr: true
|
||||
})
|
||||
editor.fabric.add(text)
|
||||
editor._create_savepoint()
|
||||
return text
|
||||
},
|
||||
|
||||
@@ -972,7 +975,6 @@ var editor = {
|
||||
rect.scaleToHeight(126)
|
||||
rect.setControlsVisibility({ mtr: false, mb: false, mt: false, mr: false, ml: false })
|
||||
editor.fabric.add(rect)
|
||||
editor._create_savepoint()
|
||||
return rect
|
||||
},
|
||||
|
||||
@@ -1009,7 +1011,6 @@ var editor = {
|
||||
mtr: true
|
||||
})
|
||||
editor.fabric.add(rect)
|
||||
editor._create_savepoint()
|
||||
$('#version-notice').show()
|
||||
return rect
|
||||
},
|
||||
@@ -1026,7 +1027,6 @@ var editor = {
|
||||
})
|
||||
rect.setControlsVisibility({ mtr: false })
|
||||
editor.fabric.add(rect)
|
||||
editor._create_savepoint()
|
||||
return rect
|
||||
},
|
||||
|
||||
@@ -1044,7 +1044,6 @@ var editor = {
|
||||
})
|
||||
rect.setControlsVisibility({ mtr: false, mb: false, mt: false, mr: false, ml: false })
|
||||
editor.fabric.add(rect)
|
||||
editor._create_savepoint()
|
||||
return rect
|
||||
},
|
||||
|
||||
|
||||
@@ -813,7 +813,13 @@ function setup_basics (el) {
|
||||
return
|
||||
}
|
||||
|
||||
$('<li><a href="#' + scrollTarget.id + '">' + $.trim(label) + '</a> – ' + description + '</li>')
|
||||
$('<li></li>')
|
||||
.append(
|
||||
$('<a></a>').attr("href", "#" + scrollTarget.id).text($.trim(label))
|
||||
)
|
||||
.append(
|
||||
document.createTextNode(' - ' + description)
|
||||
)
|
||||
.appendTo(alert.querySelector('ul') || $('<ul>').appendTo(alert))
|
||||
.find('a').on('click', function (e) {
|
||||
$panel.collapse('show')
|
||||
|
||||
@@ -157,6 +157,12 @@
|
||||
.profile-scope:last-child .profile-save-container {
|
||||
margin-bottom: -15px;
|
||||
}
|
||||
|
||||
/* the rule above removes blank space after any profile-save-container at the end of every fieldset, which causes an overlay if addon-questions are used. So re-add margin for non-addon-fieldsets followed by fieldsets (currently only happens it addon-questions are available) */
|
||||
fieldset:not(:has(.profile-add-on)):has( + fieldset) .profile-scope:last-child .profile-save-container {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.profile-save-container .help-block {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
@@ -199,6 +199,84 @@ def test_sendmail_rule_send_order_vs_pos(send_to, amount_mails, recipients, orde
|
||||
assert djmail.outbox[0].subject == 'Dummy: Foo City @ 11:30'
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@pytest.mark.parametrize('send_to,amount_mails,recipients,ticket_mail,addon_mail, products', [
|
||||
(Rule.ATTENDEES, 1, ['addon-attendee@dummy.test'], 'attendee@dummy.test', 'addon-attendee@dummy.test', 'addon'),
|
||||
(Rule.ATTENDEES, 2, ['attendee@dummy.test', 'addon-attendee@dummy.test'], 'attendee@dummy.test',
|
||||
'addon-attendee@dummy.test', 'both'),
|
||||
(Rule.ATTENDEES, 1, ['attendee@dummy.test'], 'attendee@dummy.test', 'attendee@dummy.test', 'both'),
|
||||
(Rule.ATTENDEES, 1, ['attendee@dummy.test'], 'attendee@dummy.test', None, 'addon'),
|
||||
(Rule.ATTENDEES, 1, ['attendee@dummy.test'], 'attendee@dummy.test', None, 'both'),
|
||||
(Rule.ATTENDEES, 1, ['dummy@dummy.test'], None, None, 'addon'),
|
||||
(Rule.ATTENDEES, 1, ['dummy@dummy.test'], None, None, 'both'),
|
||||
(Rule.ATTENDEES, 2, ['dummy@dummy.test', 'addon-attendee@dummy.test'], None, 'addon-attendee@dummy.test', 'both'),
|
||||
(Rule.ATTENDEES, 1, ['dummy@dummy.test'], None, None, 'all'),
|
||||
(Rule.ATTENDEES, 2, ['dummy@dummy.test', 'addon-attendee@dummy.test'], None, 'addon-attendee@dummy.test', 'all'),
|
||||
])
|
||||
@scopes_disabled()
|
||||
def test_sendmail_rule_send_addons(send_to, amount_mails, recipients, ticket_mail, addon_mail, products, order,
|
||||
event, pos, item, item2):
|
||||
djmail.outbox = []
|
||||
|
||||
order.status = order.STATUS_PAID
|
||||
order.save()
|
||||
|
||||
p = pos
|
||||
p.attendee_email = ticket_mail
|
||||
p.save()
|
||||
order.all_positions.create(item=item2, price=0, attendee_email=addon_mail, addon_to=p)
|
||||
rule = order.event.sendmail_rules.create(date_is_absolute=True, send_date=dt_now - datetime.timedelta(hours=1),
|
||||
send_to=send_to, subject='meow', template='meow meow meow',
|
||||
all_products=products == 'all')
|
||||
if products == 'addon':
|
||||
rule.limit_products.set([item2])
|
||||
if products == 'both':
|
||||
rule.limit_products.set([item, item2])
|
||||
|
||||
sendmail_run_rules(None)
|
||||
|
||||
assert len(djmail.outbox) == amount_mails
|
||||
|
||||
_recipients = [mail.to[0] for mail in djmail.outbox]
|
||||
assert set(recipients) == set(_recipients)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@pytest.mark.parametrize('send_to,amount_mails,recipients,ticket_mail,addon_mail, products', [
|
||||
(Rule.ATTENDEES, 2, ['attendee@dummy.test', 'addon-attendee@dummy.test'], 'attendee@dummy.test',
|
||||
'addon-attendee@dummy.test', 'addon'),
|
||||
(Rule.ATTENDEES, 2, ['attendee@dummy.test', 'addon-attendee@dummy.test'], 'attendee@dummy.test',
|
||||
'addon-attendee@dummy.test', 'both'),
|
||||
])
|
||||
@scopes_disabled()
|
||||
def test_sendmail_rule_send_addons_one_unp(send_to, amount_mails, recipients, ticket_mail, addon_mail, products, order,
|
||||
event, pos, item, item2):
|
||||
djmail.outbox = []
|
||||
|
||||
order.status = order.STATUS_PAID
|
||||
order.save()
|
||||
|
||||
p = pos
|
||||
p.attendee_email = ticket_mail
|
||||
p.save()
|
||||
order.all_positions.create(item=item2, price=0, attendee_email=addon_mail, addon_to=p)
|
||||
order.all_positions.create(item=item2, price=0, addon_to=p)
|
||||
rule = order.event.sendmail_rules.create(date_is_absolute=True, send_date=dt_now - datetime.timedelta(hours=1),
|
||||
send_to=send_to, subject='meow', template='meow meow meow',
|
||||
all_products=False)
|
||||
if products == 'addon':
|
||||
rule.limit_products.set([item2])
|
||||
if products == 'both':
|
||||
rule.limit_products.set([item, item2])
|
||||
|
||||
sendmail_run_rules(None)
|
||||
|
||||
assert len(djmail.outbox) == amount_mails
|
||||
|
||||
_recipients = [mail.to[0] for mail in djmail.outbox]
|
||||
assert set(recipients) == set(_recipients)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@scopes_disabled()
|
||||
def test_sendmail_rule_send_attendees_unset_mail(order, event, item):
|
||||
|
||||
@@ -406,6 +406,312 @@ def test_sendmail_attendee_product_filter(logged_in_client, sendmail_url, event,
|
||||
assert '/order/' not in djmail.outbox[0].body
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_sendmail_attendee_addon_filter(logged_in_client, sendmail_url, event, order, pos):
|
||||
event.settings.attendee_emails_asked = True
|
||||
with scopes_disabled():
|
||||
addon = Item.objects.create(name='Test addon', event=event, default_price=12)
|
||||
p = pos
|
||||
p.attendee_email = 'attendee1@dummy.test'
|
||||
p.save()
|
||||
order.positions.create(
|
||||
item=addon, price=0, attendee_email='add-on-attendee@dummy.test', addon_to=p
|
||||
)
|
||||
|
||||
djmail.outbox = []
|
||||
response = logged_in_client.post(sendmail_url + 'orders/',
|
||||
{'sendto': 'na',
|
||||
'action': 'send',
|
||||
'recipients': 'attendees',
|
||||
'items': addon.pk,
|
||||
'subject_0': 'Test subject',
|
||||
'message_0': 'This is a test file for sending mails.',
|
||||
},
|
||||
follow=True)
|
||||
assert response.status_code == 200
|
||||
assert 'alert-success' in response.rendered_content
|
||||
assert len(djmail.outbox) == 1
|
||||
assert djmail.outbox[0].to == ['add-on-attendee@dummy.test']
|
||||
assert '/ticket/' in djmail.outbox[0].body
|
||||
assert '/order/' not in djmail.outbox[0].body
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_sendmail_attendee_ticket_and_addon_filter(logged_in_client, sendmail_url, event, order, pos):
|
||||
event.settings.attendee_emails_asked = True
|
||||
with scopes_disabled():
|
||||
addon = Item.objects.create(name='Test addon', event=event, default_price=12)
|
||||
p = pos
|
||||
p.attendee_email = 'attendee1@dummy.test'
|
||||
p.save()
|
||||
order.positions.create(
|
||||
item=addon, price=0, attendee_email='add-on-attendee@dummy.test', addon_to=p
|
||||
)
|
||||
|
||||
djmail.outbox = []
|
||||
response = logged_in_client.post(sendmail_url + 'orders/',
|
||||
{'sendto': 'na',
|
||||
'action': 'send',
|
||||
'recipients': 'attendees',
|
||||
'items': {addon.pk, p.item_id},
|
||||
'subject_0': 'Test subject',
|
||||
'message_0': 'This is a test file for sending mails.',
|
||||
},
|
||||
follow=True)
|
||||
assert response.status_code == 200
|
||||
assert 'alert-success' in response.rendered_content
|
||||
assert len(djmail.outbox) == 2
|
||||
for msg in djmail.outbox:
|
||||
assert msg.to in [['attendee1@dummy.test'], ['add-on-attendee@dummy.test']]
|
||||
assert '/ticket/' in msg.body
|
||||
assert '/order/' not in msg.body
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_sendmail_attendee_ticket_and_same_addon_filter(logged_in_client, sendmail_url, event, order, pos):
|
||||
event.settings.attendee_emails_asked = True
|
||||
with scopes_disabled():
|
||||
addon = Item.objects.create(name='Test addon', event=event, default_price=12)
|
||||
p = pos
|
||||
p.attendee_email = 'attendee1@dummy.test'
|
||||
p.save()
|
||||
order.positions.create(
|
||||
item=addon, price=0, attendee_email='attendee1@dummy.test', addon_to=p
|
||||
)
|
||||
|
||||
djmail.outbox = []
|
||||
response = logged_in_client.post(sendmail_url + 'orders/',
|
||||
{'sendto': 'na',
|
||||
'action': 'send',
|
||||
'recipients': 'attendees',
|
||||
'items': {addon.pk, p.item_id},
|
||||
'subject_0': 'Test subject',
|
||||
'message_0': 'This is a test file for sending mails.',
|
||||
},
|
||||
follow=True)
|
||||
assert response.status_code == 200
|
||||
assert 'alert-success' in response.rendered_content
|
||||
assert len(djmail.outbox) == 1
|
||||
assert djmail.outbox[0].to == ['attendee1@dummy.test']
|
||||
assert '/ticket/' in djmail.outbox[0].body
|
||||
assert '/order/' not in djmail.outbox[0].body
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_sendmail_attendee_addon_unpersonalized_filter(logged_in_client, sendmail_url, event, order, pos):
|
||||
event.settings.attendee_emails_asked = True
|
||||
with scopes_disabled():
|
||||
addon = Item.objects.create(name='Test addon', event=event, default_price=12)
|
||||
p = pos
|
||||
p.attendee_email = 'attendee1@dummy.test'
|
||||
p.save()
|
||||
order.positions.create(
|
||||
item=addon, price=0, addon_to=p
|
||||
)
|
||||
|
||||
djmail.outbox = []
|
||||
response = logged_in_client.post(sendmail_url + 'orders/',
|
||||
{'sendto': 'na',
|
||||
'action': 'send',
|
||||
'recipients': 'attendees',
|
||||
'items': addon.pk,
|
||||
'subject_0': 'Test subject',
|
||||
'message_0': 'This is a test file for sending mails.',
|
||||
},
|
||||
follow=True)
|
||||
assert response.status_code == 200
|
||||
assert 'alert-success' in response.rendered_content
|
||||
assert len(djmail.outbox) == 1
|
||||
assert djmail.outbox[0].to == ['attendee1@dummy.test']
|
||||
assert '/ticket/' in djmail.outbox[0].body
|
||||
assert '/order/' not in djmail.outbox[0].body
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_sendmail_attendee_ticket_and_addon_unp_filter(logged_in_client, sendmail_url, event, order, pos):
|
||||
event.settings.attendee_emails_asked = True
|
||||
with scopes_disabled():
|
||||
addon = Item.objects.create(name='Test addon', event=event, default_price=12)
|
||||
p = pos
|
||||
p.attendee_email = 'attendee1@dummy.test'
|
||||
p.save()
|
||||
order.positions.create(
|
||||
item=addon, price=0, addon_to=p
|
||||
)
|
||||
|
||||
djmail.outbox = []
|
||||
response = logged_in_client.post(sendmail_url + 'orders/',
|
||||
{'sendto': 'na',
|
||||
'action': 'send',
|
||||
'recipients': 'attendees',
|
||||
'items': {addon.pk, p.item_id},
|
||||
'subject_0': 'Test subject',
|
||||
'message_0': 'This is a test file for sending mails.',
|
||||
},
|
||||
follow=True)
|
||||
assert response.status_code == 200
|
||||
assert 'alert-success' in response.rendered_content
|
||||
assert len(djmail.outbox) == 1
|
||||
assert djmail.outbox[0].to == ['attendee1@dummy.test']
|
||||
assert '/ticket/' in djmail.outbox[0].body
|
||||
assert '/order/' not in djmail.outbox[0].body
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_sendmail_attendee_ticket_unp_and_addon_filter(logged_in_client, sendmail_url, event, order, pos):
|
||||
event.settings.attendee_emails_asked = True
|
||||
with scopes_disabled():
|
||||
addon = Item.objects.create(name='Test addon', event=event, default_price=12)
|
||||
order.positions.create(
|
||||
item=addon, price=0, attendee_email='add-on-attendee@dummy.test', addon_to=pos
|
||||
)
|
||||
|
||||
djmail.outbox = []
|
||||
response = logged_in_client.post(sendmail_url + 'orders/',
|
||||
{'sendto': 'na',
|
||||
'action': 'send',
|
||||
'recipients': 'attendees',
|
||||
'items': {addon.pk, pos.item_id},
|
||||
'subject_0': 'Test subject',
|
||||
'message_0': 'This is a test file for sending mails.',
|
||||
},
|
||||
follow=True)
|
||||
assert response.status_code == 200
|
||||
assert 'alert-success' in response.rendered_content
|
||||
assert len(djmail.outbox) == 2
|
||||
for msg in djmail.outbox:
|
||||
assert msg.to in [[order.email], ['add-on-attendee@dummy.test']]
|
||||
if msg.to == [order.email]:
|
||||
assert '/ticket/' not in msg.body
|
||||
assert '/order/' in msg.body
|
||||
else:
|
||||
assert msg.to == ['add-on-attendee@dummy.test']
|
||||
assert '/ticket/' in msg.body
|
||||
assert '/order/' not in msg.body
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_sendmail_attendee_addon_unp_unp_filter(logged_in_client, sendmail_url, event, order, pos):
|
||||
event.settings.attendee_emails_asked = True
|
||||
with scopes_disabled():
|
||||
addon = Item.objects.create(name='Test addon', event=event, default_price=12)
|
||||
order.positions.create(
|
||||
item=addon, price=0, addon_to=pos
|
||||
)
|
||||
|
||||
djmail.outbox = []
|
||||
response = logged_in_client.post(sendmail_url + 'orders/',
|
||||
{'sendto': 'na',
|
||||
'action': 'send',
|
||||
'recipients': 'attendees',
|
||||
'items': addon.pk,
|
||||
'subject_0': 'Test subject',
|
||||
'message_0': 'This is a test file for sending mails.',
|
||||
},
|
||||
follow=True)
|
||||
assert response.status_code == 200
|
||||
assert 'alert-success' in response.rendered_content
|
||||
assert len(djmail.outbox) == 1
|
||||
assert djmail.outbox[0].to == [order.email]
|
||||
assert '/ticket/' not in djmail.outbox[0].body
|
||||
assert '/order/' in djmail.outbox[0].body
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_sendmail_attendee_and_addon_unp_unp_filter(logged_in_client, sendmail_url, event, order, pos):
|
||||
event.settings.attendee_emails_asked = True
|
||||
with scopes_disabled():
|
||||
addon = Item.objects.create(name='Test addon', event=event, default_price=12)
|
||||
order.positions.create(
|
||||
item=addon, price=0, addon_to=pos
|
||||
)
|
||||
|
||||
djmail.outbox = []
|
||||
response = logged_in_client.post(sendmail_url + 'orders/',
|
||||
{'sendto': 'na',
|
||||
'action': 'send',
|
||||
'recipients': 'attendees',
|
||||
'items': {addon.pk, pos.item_id},
|
||||
'subject_0': 'Test subject',
|
||||
'message_0': 'This is a test file for sending mails.',
|
||||
},
|
||||
follow=True)
|
||||
assert response.status_code == 200
|
||||
assert 'alert-success' in response.rendered_content
|
||||
assert len(djmail.outbox) == 1
|
||||
assert djmail.outbox[0].to == [order.email]
|
||||
assert '/ticket/' not in djmail.outbox[0].body
|
||||
assert '/order/' in djmail.outbox[0].body
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_sendmail_attendee_two_addons_one_unp_filter(logged_in_client, sendmail_url, event, order, pos):
|
||||
event.settings.attendee_emails_asked = True
|
||||
with scopes_disabled():
|
||||
p = pos
|
||||
p.attendee_email = 'attendee1@dummy.test'
|
||||
p.save()
|
||||
addon = Item.objects.create(name='Test addon', event=event, default_price=12)
|
||||
order.positions.create(
|
||||
item=addon, price=0, attendee_email='add-on-attendee@dummy.test', addon_to=p
|
||||
)
|
||||
order.positions.create(
|
||||
item=addon, price=0, addon_to=p
|
||||
)
|
||||
|
||||
djmail.outbox = []
|
||||
response = logged_in_client.post(sendmail_url + 'orders/',
|
||||
{'sendto': 'na',
|
||||
'action': 'send',
|
||||
'recipients': 'attendees',
|
||||
'items': addon.pk,
|
||||
'subject_0': 'Test subject',
|
||||
'message_0': 'This is a test file for sending mails.',
|
||||
},
|
||||
follow=True)
|
||||
assert response.status_code == 200
|
||||
assert 'alert-success' in response.rendered_content
|
||||
assert len(djmail.outbox) == 2
|
||||
for msg in djmail.outbox:
|
||||
assert msg.to in [['attendee1@dummy.test'], ['add-on-attendee@dummy.test']]
|
||||
assert '/ticket/' in msg.body
|
||||
assert '/order/' not in msg.body
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_sendmail_attendee_and_two_addons_one_unp_filter(logged_in_client, sendmail_url, event, order, pos):
|
||||
event.settings.attendee_emails_asked = True
|
||||
with scopes_disabled():
|
||||
p = pos
|
||||
p.attendee_email = 'attendee1@dummy.test'
|
||||
p.save()
|
||||
addon = Item.objects.create(name='Test addon', event=event, default_price=12)
|
||||
order.positions.create(
|
||||
item=addon, price=0, attendee_email='add-on-attendee@dummy.test', addon_to=p
|
||||
)
|
||||
order.positions.create(
|
||||
item=addon, price=0, addon_to=p
|
||||
)
|
||||
|
||||
djmail.outbox = []
|
||||
response = logged_in_client.post(sendmail_url + 'orders/',
|
||||
{'sendto': 'na',
|
||||
'action': 'send',
|
||||
'recipients': 'attendees',
|
||||
'items': {addon.pk, p.item_id},
|
||||
'subject_0': 'Test subject',
|
||||
'message_0': 'This is a test file for sending mails.',
|
||||
},
|
||||
follow=True)
|
||||
assert response.status_code == 200
|
||||
assert 'alert-success' in response.rendered_content
|
||||
assert len(djmail.outbox) == 2
|
||||
for msg in djmail.outbox:
|
||||
assert msg.to in [['attendee1@dummy.test'], ['add-on-attendee@dummy.test']]
|
||||
assert '/ticket/' in msg.body
|
||||
assert '/order/' not in msg.body
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_sendmail_attendee_subevent_filter(logged_in_client, sendmail_url, event, item, order, pos):
|
||||
event.settings.attendee_emails_asked = True
|
||||
|
||||
Reference in New Issue
Block a user