forked from CGM_Public/pretix_original
Sendmail: Allow to attach tickets to emails
This commit is contained in:
@@ -612,7 +612,7 @@ class OrderMailForm(forms.Form):
|
|||||||
)
|
)
|
||||||
attach_tickets = forms.BooleanField(
|
attach_tickets = forms.BooleanField(
|
||||||
label=_("Attach tickets"),
|
label=_("Attach tickets"),
|
||||||
help_text=_("Will be ignored if all tickets in this order exceed a given size limit to ensure email deliverability."),
|
help_text=_("Will be ignored if tickets exceed a given size limit to ensure email deliverability."),
|
||||||
required=False
|
required=False
|
||||||
)
|
)
|
||||||
attach_invoices = forms.ModelMultipleChoiceField(
|
attach_invoices = forms.ModelMultipleChoiceField(
|
||||||
|
|||||||
@@ -132,6 +132,11 @@ class MailForm(FormPlaceholderMixin, forms.Form):
|
|||||||
label=pgettext_lazy('subevent', 'Only send to customers with orders created before'),
|
label=pgettext_lazy('subevent', 'Only send to customers with orders created before'),
|
||||||
required=False,
|
required=False,
|
||||||
)
|
)
|
||||||
|
attach_tickets = forms.BooleanField(
|
||||||
|
label=_("Attach tickets"),
|
||||||
|
help_text=_("Will be ignored if tickets exceed a given size limit to ensure email deliverability."),
|
||||||
|
required=False
|
||||||
|
)
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
d = super().clean()
|
d = super().clean()
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ from pretix.celery_app import app
|
|||||||
@app.task(base=ProfiledEventTask, acks_late=True)
|
@app.task(base=ProfiledEventTask, acks_late=True)
|
||||||
def send_mails(event: Event, user: int, subject: dict, message: dict, orders: list, items: list,
|
def send_mails(event: Event, user: int, subject: dict, message: dict, orders: list, items: list,
|
||||||
recipients: str, filter_checkins: bool, not_checked_in: bool, checkin_lists: list,
|
recipients: str, filter_checkins: bool, not_checked_in: bool, checkin_lists: list,
|
||||||
attachments: list = None) -> None:
|
attachments: list = None, attach_tickets: bool = False) -> None:
|
||||||
failures = []
|
failures = []
|
||||||
user = User.objects.get(pk=user) if user else None
|
user = User.objects.get(pk=user) if user else None
|
||||||
orders = Order.objects.filter(pk__in=orders, event=event)
|
orders = Order.objects.filter(pk__in=orders, event=event)
|
||||||
@@ -97,6 +97,7 @@ def send_mails(event: Event, user: int, subject: dict, message: dict, orders: li
|
|||||||
locale=o.locale,
|
locale=o.locale,
|
||||||
order=o,
|
order=o,
|
||||||
position=p,
|
position=p,
|
||||||
|
attach_tickets=attach_tickets,
|
||||||
attach_cached_files=attachments
|
attach_cached_files=attachments
|
||||||
)
|
)
|
||||||
o.log_action(
|
o.log_action(
|
||||||
@@ -124,6 +125,7 @@ def send_mails(event: Event, user: int, subject: dict, message: dict, orders: li
|
|||||||
event,
|
event,
|
||||||
locale=o.locale,
|
locale=o.locale,
|
||||||
order=o,
|
order=o,
|
||||||
|
attach_tickets=attach_tickets,
|
||||||
attach_cached_files=attachments
|
attach_cached_files=attachments
|
||||||
)
|
)
|
||||||
o.log_action(
|
o.log_action(
|
||||||
|
|||||||
@@ -53,6 +53,7 @@
|
|||||||
{% bootstrap_field form.subject layout='horizontal' %}
|
{% bootstrap_field form.subject layout='horizontal' %}
|
||||||
{% bootstrap_field form.message layout='horizontal' %}
|
{% bootstrap_field form.message layout='horizontal' %}
|
||||||
{% bootstrap_field form.attachment layout='horizontal' %}
|
{% bootstrap_field form.attachment layout='horizontal' %}
|
||||||
|
{% bootstrap_field form.attach_tickets layout='horizontal' %}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
{% if is_preview %}
|
{% if is_preview %}
|
||||||
<fieldset>
|
<fieldset>
|
||||||
@@ -65,12 +66,18 @@
|
|||||||
{% if out.attachment %}
|
{% if out.attachment %}
|
||||||
<p>
|
<p>
|
||||||
<a href="{% url 'cachedfile.download' id=out.attachment.id %}" class="btn btn-default"
|
<a href="{% url 'cachedfile.download' id=out.attachment.id %}" class="btn btn-default"
|
||||||
target="_blank">
|
target="_blank">
|
||||||
<span class="fa fa-file" aria-hidden="true"></span>
|
<span class="fa fa-file" aria-hidden="true"></span>
|
||||||
{{ out.attachment.filename }}
|
{{ out.attachment.filename }}
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if form.cleaned_data.attach_tickets %}
|
||||||
|
<p>
|
||||||
|
<span class="fa fa-file" aria-hidden="true"></span>
|
||||||
|
{% trans "Tickets" %}
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -108,6 +108,8 @@ class SenderView(EventPermissionRequiredMixin, FormView):
|
|||||||
kwargs['initial']['created_from'] = dateutil.parser.parse(logentry.parsed_data['created_from'])
|
kwargs['initial']['created_from'] = dateutil.parser.parse(logentry.parsed_data['created_from'])
|
||||||
if logentry.parsed_data.get('created_to'):
|
if logentry.parsed_data.get('created_to'):
|
||||||
kwargs['initial']['created_to'] = dateutil.parser.parse(logentry.parsed_data['created_to'])
|
kwargs['initial']['created_to'] = dateutil.parser.parse(logentry.parsed_data['created_to'])
|
||||||
|
if logentry.parsed_data.get('attach_tickets'):
|
||||||
|
kwargs['initial']['attach_tickets'] = logentry.parsed_data['attach_tickets']
|
||||||
if logentry.parsed_data.get('subevent'):
|
if logentry.parsed_data.get('subevent'):
|
||||||
try:
|
try:
|
||||||
kwargs['initial']['subevent'] = self.request.event.subevents.get(
|
kwargs['initial']['subevent'] = self.request.event.subevents.get(
|
||||||
@@ -229,6 +231,7 @@ class SenderView(EventPermissionRequiredMixin, FormView):
|
|||||||
'not_checked_in': form.cleaned_data.get('not_checked_in'),
|
'not_checked_in': form.cleaned_data.get('not_checked_in'),
|
||||||
'checkin_lists': [i.pk for i in form.cleaned_data.get('checkin_lists')],
|
'checkin_lists': [i.pk for i in form.cleaned_data.get('checkin_lists')],
|
||||||
'filter_checkins': form.cleaned_data.get('filter_checkins'),
|
'filter_checkins': form.cleaned_data.get('filter_checkins'),
|
||||||
|
'attach_tickets': form.cleaned_data.get('attach_tickets'),
|
||||||
}
|
}
|
||||||
attachment = form.cleaned_data.get('attachment')
|
attachment = form.cleaned_data.get('attachment')
|
||||||
if attachment is not None and attachment is not False:
|
if attachment is not None and attachment is not False:
|
||||||
|
|||||||
Reference in New Issue
Block a user