mirror of
https://github.com/pretix/pretix.git
synced 2025-12-05 21:32:28 +00:00
Compare commits
1 Commits
context-on
...
order-emai
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a8f2dc6a7 |
@@ -1199,6 +1199,8 @@ class Order(LockModel, LoggedModel):
|
||||
'invoices': [i.pk for i in invoices] if invoices else [],
|
||||
'attach_tickets': attach_tickets,
|
||||
'attach_ical': attach_ical,
|
||||
'attach_other_files': attach_other_files,
|
||||
'attach_cached_files': [cf.filename for cf in attach_cached_files] if attach_cached_files else [],
|
||||
}
|
||||
)
|
||||
|
||||
@@ -2857,6 +2859,8 @@ class OrderPosition(AbstractPosition):
|
||||
'invoices': [i.pk for i in invoices] if invoices else [],
|
||||
'attach_tickets': attach_tickets,
|
||||
'attach_ical': attach_ical,
|
||||
'attach_other_files': attach_other_files,
|
||||
'attach_cached_files': [],
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -286,6 +286,8 @@ class WaitingListEntry(LoggedModel):
|
||||
'subject': subject,
|
||||
'message': email_content,
|
||||
'recipient': recipient,
|
||||
'attach_other_files': attach_other_files,
|
||||
'attach_cached_files': [cf.filename for cf in attach_cached_files] if attach_cached_files else [],
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -51,6 +51,41 @@
|
||||
{{ log.parsed_data.subject }}</strong>
|
||||
</p>
|
||||
<pre>{{ log.parsed_data.message }}</pre>
|
||||
<ul class="list-unstyled">
|
||||
{% if log.parsed_data.attach_tickets %}
|
||||
<li><span class="fa fa-files-o fa-fw"></span> {% trans "Tickets" %}</li>
|
||||
{% endif %}
|
||||
{% if log.parsed_data.attach_ical %}
|
||||
<li><span class="fa fa-calendar-o fa-fw"></span> {% trans "Calendar invite" %}</li>
|
||||
{% endif %}
|
||||
{% if log.parsed_data.invoices %}
|
||||
{% for i in log.parsed_invoices %}
|
||||
<li>
|
||||
<span class="fa fa-file-o fa-fw"></span>
|
||||
<a href="{% url "control:event.invoice.download" invoice=i.pk event=request.event.slug organizer=request.event.organizer.slug %}" target="_blank">
|
||||
{% if i.is_cancellation %}{% trans "Cancellation" context "invoice" %}{% else %}{% trans "Invoice" %}{% endif %}
|
||||
{{ i.number }}
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if log.parsed_data.attach_other_files %}
|
||||
{% for f in log.parsed_other_files %}
|
||||
<li>
|
||||
<span class="fa fa-file-o fa-fw"></span>
|
||||
{{ f }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if log.parsed_data.attach_cached_files %}
|
||||
{% for f in log.parsed_data.attach_cached_files %}
|
||||
<li>
|
||||
<span class="fa fa-file-o fa-fw"></span>
|
||||
{{ f }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
||||
@@ -135,6 +135,7 @@ from pretix.control.views import PaginationMixin
|
||||
from pretix.helpers import OF_SELF
|
||||
from pretix.helpers.compat import CompatDeleteView
|
||||
from pretix.helpers.format import SafeFormatter, format_map
|
||||
from pretix.helpers.hierarkey import clean_filename
|
||||
from pretix.helpers.safedownload import check_token
|
||||
from pretix.presale.signals import question_form_fields
|
||||
|
||||
@@ -2461,6 +2462,20 @@ class OrderEmailHistory(EventPermissionRequiredMixin, OrderViewMixin, ListView):
|
||||
)
|
||||
return qs
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
ctx = super().get_context_data(**kwargs)
|
||||
for l in ctx["logs"]:
|
||||
if l.parsed_data.get("invoices"):
|
||||
l.parsed_invoices = Invoice.objects.filter(
|
||||
event=self.request.event,
|
||||
pk__in=l.parsed_data["invoices"],
|
||||
)
|
||||
if l.parsed_data.get("attach_other_files"):
|
||||
l.parsed_other_files = [
|
||||
clean_filename(os.path.basename(f)) for f in l.parsed_data["attach_other_files"]
|
||||
]
|
||||
return ctx
|
||||
|
||||
|
||||
class AnswerDownload(EventPermissionRequiredMixin, OrderViewMixin, ListView):
|
||||
permission = 'can_view_orders'
|
||||
|
||||
@@ -38,7 +38,9 @@ from i18nfield.strings import LazyI18nString
|
||||
|
||||
from pretix.base.email import get_email_context
|
||||
from pretix.base.i18n import language
|
||||
from pretix.base.models import Checkin, Event, InvoiceAddress, Order, User
|
||||
from pretix.base.models import (
|
||||
CachedFile, Checkin, Event, InvoiceAddress, Order, User,
|
||||
)
|
||||
from pretix.base.services.mail import SendMailException, mail
|
||||
from pretix.base.services.tasks import ProfiledEventTask
|
||||
from pretix.celery_app import app
|
||||
@@ -56,6 +58,7 @@ def send_mails_to_orders(event: Event, user: int, subject: dict, message: dict,
|
||||
orders = Order.objects.filter(pk__in=objects, event=event)
|
||||
subject = LazyI18nString(subject)
|
||||
message = LazyI18nString(message)
|
||||
attachments_for_log = [cf.filename for cf in CachedFile.objects.filter(pk__in=attachments)] if attachments else []
|
||||
|
||||
for o in orders:
|
||||
send_to_order = recipients in ('both', 'orders')
|
||||
@@ -134,7 +137,11 @@ def send_mails_to_orders(event: Event, user: int, subject: dict, message: dict,
|
||||
'position': p.positionid,
|
||||
'subject': format_map(subject.localize(o.locale), email_context),
|
||||
'message': format_map(message.localize(o.locale), email_context),
|
||||
'recipient': p.attendee_email
|
||||
'recipient': p.attendee_email,
|
||||
'attach_tickets': attach_tickets,
|
||||
'attach_ical': attach_ical,
|
||||
'attach_other_files': [],
|
||||
'attach_cached_files': attachments_for_log,
|
||||
}
|
||||
)
|
||||
except SendMailException:
|
||||
@@ -162,7 +169,11 @@ def send_mails_to_orders(event: Event, user: int, subject: dict, message: dict,
|
||||
data={
|
||||
'subject': format_map(subject.localize(o.locale), email_context),
|
||||
'message': format_map(message.localize(o.locale), email_context),
|
||||
'recipient': o.email
|
||||
'recipient': o.email,
|
||||
'attach_tickets': attach_tickets,
|
||||
'attach_ical': attach_ical,
|
||||
'attach_other_files': [],
|
||||
'attach_cached_files': attachments_for_log,
|
||||
}
|
||||
)
|
||||
except SendMailException:
|
||||
|
||||
@@ -45,27 +45,28 @@
|
||||
<div lang="{{ locale }}" class="mail-preview">
|
||||
<strong>{{ out.subject|safe }}</strong><br><br>
|
||||
{{ out.html|safe }}
|
||||
{% if out.attachment %}
|
||||
<p>
|
||||
<a href="{% url 'cachedfile.download' id=out.attachment.id %}" class="btn btn-default"
|
||||
target="_blank">
|
||||
<span class="fa fa-file" aria-hidden="true"></span>
|
||||
{{ out.attachment.filename }}
|
||||
</a>
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if form.cleaned_data.attach_tickets %}
|
||||
<p>
|
||||
<span class="fa fa-file" aria-hidden="true"></span>
|
||||
{% trans "Tickets" %}
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if form.cleaned_data.attach_ical %}
|
||||
<p>
|
||||
<span class="fa fa-file" aria-hidden="true"></span>
|
||||
{% trans "Attach calendar files" %}
|
||||
</p>
|
||||
{% endif %}
|
||||
<ul class="list-unstyled">
|
||||
{% if out.attachment %}
|
||||
<li>
|
||||
<span class="fa fa-file-o fa-fw" aria-hidden="true"></span>
|
||||
<a href="{% url 'cachedfile.download' id=out.attachment.id %}" target="_blank">
|
||||
{{ out.attachment.filename }}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if form.cleaned_data.attach_tickets %}
|
||||
<li>
|
||||
<span class="fa fa-file-o fa-fw" aria-hidden="true"></span>
|
||||
{% trans "Tickets" %}
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if form.cleaned_data.attach_ical %}
|
||||
<li>
|
||||
<span class="fa fa-calendar-o fa-fw" aria-hidden="true"></span>
|
||||
{% trans "Attach calendar files" %}
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user