forked from CGM_Public/pretix_original
Sendmail: Fix incorrect filtering of subevents when mailing to attendees (Z#23166274) (#4474)
This commit is contained in:
@@ -31,6 +31,8 @@
|
||||
# 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.
|
||||
from datetime import datetime
|
||||
|
||||
from django.db.models import Exists, OuterRef, Q
|
||||
from i18nfield.strings import LazyI18nString
|
||||
|
||||
@@ -45,6 +47,7 @@ from pretix.helpers.format import format_map
|
||||
|
||||
@app.task(base=ProfiledEventTask, acks_late=True)
|
||||
def send_mails_to_orders(event: Event, user: int, subject: dict, message: dict, objects: list, items: list,
|
||||
subevent: int, subevents_from: datetime, subevents_to: datetime,
|
||||
recipients: str, filter_checkins: bool, not_checked_in: bool, checkin_lists: list,
|
||||
attachments: list = None, attach_tickets: bool = False,
|
||||
attach_ical: bool = False) -> None:
|
||||
@@ -76,7 +79,7 @@ def send_mails_to_orders(event: Event, user: int, subject: dict, message: dict,
|
||||
list_id__in=checkin_lists or []
|
||||
)
|
||||
),
|
||||
).prefetch_related('addons'):
|
||||
).prefetch_related('addons', 'subevent'):
|
||||
if p.addon_to_id is not None:
|
||||
continue
|
||||
|
||||
@@ -99,6 +102,15 @@ def send_mails_to_orders(event: Event, user: int, subject: dict, message: dict,
|
||||
if p.attendee_email == o.email and send_to_order:
|
||||
continue
|
||||
|
||||
if subevent and p.subevent_id != subevent:
|
||||
continue
|
||||
|
||||
if subevents_from and p.subevent.date_from < subevents_from:
|
||||
continue
|
||||
|
||||
if subevents_to and p.subevent.date_from >= subevents_to:
|
||||
continue
|
||||
|
||||
try:
|
||||
with language(o.locale, event.settings.region):
|
||||
email_context = get_email_context(event=event, order=o, invoice_address=ia, position=p)
|
||||
|
||||
@@ -429,6 +429,9 @@ class OrderSendView(BaseSenderView):
|
||||
kwargs.update({
|
||||
'recipients': form.cleaned_data['recipients'],
|
||||
'items': [i.pk for i in form.cleaned_data.get('items')],
|
||||
'subevent': form.cleaned_data['subevent'].pk if form.cleaned_data.get('subevent') else None,
|
||||
'subevents_from': form.cleaned_data.get('subevents_from'),
|
||||
'subevents_to': form.cleaned_data.get('subevents_to'),
|
||||
'not_checked_in': form.cleaned_data.get('not_checked_in'),
|
||||
'checkin_lists': [i.pk for i in form.cleaned_data.get('checkin_lists')],
|
||||
'filter_checkins': form.cleaned_data.get('filter_checkins'),
|
||||
|
||||
Reference in New Issue
Block a user