forked from CGM_Public/pretix_original
New email placeholders invoice_name, invoice_company
This commit is contained in:
@@ -11,7 +11,7 @@ from django.utils.translation import ugettext as _
|
|||||||
from inlinestyler.utils import inline_css
|
from inlinestyler.utils import inline_css
|
||||||
|
|
||||||
from pretix.base.i18n import LazyI18nString, language
|
from pretix.base.i18n import LazyI18nString, language
|
||||||
from pretix.base.models import Event, Order
|
from pretix.base.models import Event, InvoiceAddress, Order
|
||||||
from pretix.celery_app import app
|
from pretix.celery_app import app
|
||||||
from pretix.multidomain.urlreverse import build_absolute_uri
|
from pretix.multidomain.urlreverse import build_absolute_uri
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ def mail(email: str, subject: str, template: str,
|
|||||||
|
|
||||||
:param template: The filename of a template to be used. It will be rendered with the locale given in the locale
|
:param template: The filename of a template to be used. It will be rendered with the locale given in the locale
|
||||||
argument and the context given in the next argument. Alternatively, you can pass a LazyI18nString and
|
argument and the context given in the next argument. Alternatively, you can pass a LazyI18nString and
|
||||||
``context`` will be used as the argument to a Python ``.format()`` call on the template.
|
``context`` will be used as the argument to a Python ``.format_map()`` call on the template.
|
||||||
|
|
||||||
:param context: The context for rendering the template (see ``template`` parameter)
|
:param context: The context for rendering the template (see ``template`` parameter)
|
||||||
|
|
||||||
@@ -64,6 +64,17 @@ def mail(email: str, subject: str, template: str,
|
|||||||
return
|
return
|
||||||
|
|
||||||
with language(locale):
|
with language(locale):
|
||||||
|
if isinstance(context, dict) and order:
|
||||||
|
try:
|
||||||
|
context.update({
|
||||||
|
'invoice_name': order.invoice_address.name,
|
||||||
|
'invoice_company': order.invoice_address.company
|
||||||
|
})
|
||||||
|
except InvoiceAddress.DoesNotExist:
|
||||||
|
context.update({
|
||||||
|
'invoice_name': '',
|
||||||
|
'invoice_company': ''
|
||||||
|
})
|
||||||
if isinstance(template, LazyI18nString):
|
if isinstance(template, LazyI18nString):
|
||||||
body = str(template)
|
body = str(template)
|
||||||
if context:
|
if context:
|
||||||
|
|||||||
@@ -106,6 +106,12 @@ def mark_order_paid(order: Order, provider: str=None, info: str=None, date: date
|
|||||||
|
|
||||||
if send_mail:
|
if send_mail:
|
||||||
with language(order.locale):
|
with language(order.locale):
|
||||||
|
try:
|
||||||
|
invoice_name = order.invoice_address.name
|
||||||
|
invoice_company = order.invoice_address.company
|
||||||
|
except InvoiceAddress.DoesNotExist:
|
||||||
|
invoice_name = ""
|
||||||
|
invoice_company = ""
|
||||||
mail(
|
mail(
|
||||||
order.email, _('Payment received for your order: %(code)s') % {'code': order.code},
|
order.email, _('Payment received for your order: %(code)s') % {'code': order.code},
|
||||||
order.event.settings.mail_text_order_paid,
|
order.event.settings.mail_text_order_paid,
|
||||||
@@ -115,7 +121,9 @@ def mark_order_paid(order: Order, provider: str=None, info: str=None, date: date
|
|||||||
'order': order.code,
|
'order': order.code,
|
||||||
'secret': order.secret
|
'secret': order.secret
|
||||||
}),
|
}),
|
||||||
'downloads': order.event.settings.get('ticket_download', as_type=bool)
|
'downloads': order.event.settings.get('ticket_download', as_type=bool),
|
||||||
|
'invoice_name': invoice_name,
|
||||||
|
'invoice_company': invoice_company,
|
||||||
},
|
},
|
||||||
order.event, locale=order.locale
|
order.event, locale=order.locale
|
||||||
)
|
)
|
||||||
@@ -363,6 +371,14 @@ def _perform_order(event: str, payment_provider: str, position_ids: List[str],
|
|||||||
mailtext = event.settings.mail_text_order_free
|
mailtext = event.settings.mail_text_order_free
|
||||||
else:
|
else:
|
||||||
mailtext = event.settings.mail_text_order_placed
|
mailtext = event.settings.mail_text_order_placed
|
||||||
|
|
||||||
|
try:
|
||||||
|
invoice_name = order.invoice_address.name
|
||||||
|
invoice_company = order.invoice_address.company
|
||||||
|
except InvoiceAddress.DoesNotExist:
|
||||||
|
invoice_name = ""
|
||||||
|
invoice_company = ""
|
||||||
|
|
||||||
mail(
|
mail(
|
||||||
order.email, _('Your order: %(code)s') % {'code': order.code},
|
order.email, _('Your order: %(code)s') % {'code': order.code},
|
||||||
mailtext,
|
mailtext,
|
||||||
@@ -375,7 +391,9 @@ def _perform_order(event: str, payment_provider: str, position_ids: List[str],
|
|||||||
'order': order.code,
|
'order': order.code,
|
||||||
'secret': order.secret
|
'secret': order.secret
|
||||||
}),
|
}),
|
||||||
'paymentinfo': str(pprov.order_pending_mail_render(order))
|
'paymentinfo': str(pprov.order_pending_mail_render(order)),
|
||||||
|
'invoice_name': invoice_name,
|
||||||
|
'invoice_company': invoice_company,
|
||||||
},
|
},
|
||||||
event, locale=order.locale
|
event, locale=order.locale
|
||||||
)
|
)
|
||||||
@@ -413,6 +431,12 @@ def send_expiry_warnings(sender, **kwargs):
|
|||||||
if days and (o.expires - today).days <= days:
|
if days and (o.expires - today).days <= days:
|
||||||
o.expiry_reminder_sent = True
|
o.expiry_reminder_sent = True
|
||||||
o.save()
|
o.save()
|
||||||
|
try:
|
||||||
|
invoice_name = o.invoice_address.name
|
||||||
|
invoice_company = o.invoice_address.company
|
||||||
|
except InvoiceAddress.DoesNotExist:
|
||||||
|
invoice_name = ""
|
||||||
|
invoice_company = ""
|
||||||
try:
|
try:
|
||||||
mail(
|
mail(
|
||||||
o.email, _('Your order is about to expire: %(code)s') % {'code': o.code},
|
o.email, _('Your order is about to expire: %(code)s') % {'code': o.code},
|
||||||
@@ -423,7 +447,9 @@ def send_expiry_warnings(sender, **kwargs):
|
|||||||
'order': o.code,
|
'order': o.code,
|
||||||
'secret': o.secret
|
'secret': o.secret
|
||||||
}),
|
}),
|
||||||
'expire_date': date_format(o.expires, 'SHORT_DATE_FORMAT')
|
'expire_date': date_format(o.expires, 'SHORT_DATE_FORMAT'),
|
||||||
|
'invoice_name': invoice_name,
|
||||||
|
'invoice_company': invoice_company,
|
||||||
},
|
},
|
||||||
o.event, locale=o.locale
|
o.event, locale=o.locale
|
||||||
)
|
)
|
||||||
@@ -557,6 +583,12 @@ class OrderChangeManager:
|
|||||||
|
|
||||||
def _notify_user(self):
|
def _notify_user(self):
|
||||||
with language(self.order.locale):
|
with language(self.order.locale):
|
||||||
|
try:
|
||||||
|
invoice_name = self.order.invoice_address.name
|
||||||
|
invoice_company = self.order.invoice_address.company
|
||||||
|
except InvoiceAddress.DoesNotExist:
|
||||||
|
invoice_name = ""
|
||||||
|
invoice_company = ""
|
||||||
mail(
|
mail(
|
||||||
self.order.email, _('Your order has been changed: %(code)s') % {'code': self.order.code},
|
self.order.email, _('Your order has been changed: %(code)s') % {'code': self.order.code},
|
||||||
self.order.event.settings.mail_text_order_changed,
|
self.order.event.settings.mail_text_order_changed,
|
||||||
@@ -566,6 +598,8 @@ class OrderChangeManager:
|
|||||||
'order': self.order.code,
|
'order': self.order.code,
|
||||||
'secret': self.order.secret
|
'secret': self.order.secret
|
||||||
}),
|
}),
|
||||||
|
'invoice_name': invoice_name,
|
||||||
|
'invoice_company': invoice_company,
|
||||||
},
|
},
|
||||||
self.order.event, locale=self.order.locale
|
self.order.event, locale=self.order.locale
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -378,31 +378,32 @@ class MailSettingsForm(SettingsForm):
|
|||||||
label=_("Text"),
|
label=_("Text"),
|
||||||
required=False,
|
required=False,
|
||||||
widget=I18nTextarea,
|
widget=I18nTextarea,
|
||||||
help_text=_("Available placeholders: {event}, {total}, {currency}, {date}, {paymentinfo}, {url}")
|
help_text=_("Available placeholders: {event}, {total}, {currency}, {date}, {paymentinfo}, {url}, "
|
||||||
|
"{invoice_name}, {invoice_company}")
|
||||||
)
|
)
|
||||||
mail_text_order_paid = I18nFormField(
|
mail_text_order_paid = I18nFormField(
|
||||||
label=_("Text"),
|
label=_("Text"),
|
||||||
required=False,
|
required=False,
|
||||||
widget=I18nTextarea,
|
widget=I18nTextarea,
|
||||||
help_text=_("Available placeholders: {event}, {url}")
|
help_text=_("Available placeholders: {event}, {url}, {invoice_name}, {invoice_company}")
|
||||||
)
|
)
|
||||||
mail_text_order_free = I18nFormField(
|
mail_text_order_free = I18nFormField(
|
||||||
label=_("Text"),
|
label=_("Text"),
|
||||||
required=False,
|
required=False,
|
||||||
widget=I18nTextarea,
|
widget=I18nTextarea,
|
||||||
help_text=_("Available placeholders: {event}, {url}")
|
help_text=_("Available placeholders: {event}, {url}, {invoice_name}, {invoice_company}")
|
||||||
)
|
)
|
||||||
mail_text_order_changed = I18nFormField(
|
mail_text_order_changed = I18nFormField(
|
||||||
label=_("Text"),
|
label=_("Text"),
|
||||||
required=False,
|
required=False,
|
||||||
widget=I18nTextarea,
|
widget=I18nTextarea,
|
||||||
help_text=_("Available placeholders: {event}, {url}")
|
help_text=_("Available placeholders: {event}, {url}, {invoice_name}, {invoice_company}")
|
||||||
)
|
)
|
||||||
mail_text_resend_link = I18nFormField(
|
mail_text_resend_link = I18nFormField(
|
||||||
label=_("Text (sent by admin)"),
|
label=_("Text (sent by admin)"),
|
||||||
required=False,
|
required=False,
|
||||||
widget=I18nTextarea,
|
widget=I18nTextarea,
|
||||||
help_text=_("Available placeholders: {event}, {url}")
|
help_text=_("Available placeholders: {event}, {url}, {invoice_name}, {invoice_company}")
|
||||||
)
|
)
|
||||||
mail_text_resend_all_links = I18nFormField(
|
mail_text_resend_all_links = I18nFormField(
|
||||||
label=_("Text (requested by user)"),
|
label=_("Text (requested by user)"),
|
||||||
@@ -421,7 +422,7 @@ class MailSettingsForm(SettingsForm):
|
|||||||
label=_("Text"),
|
label=_("Text"),
|
||||||
required=False,
|
required=False,
|
||||||
widget=I18nTextarea,
|
widget=I18nTextarea,
|
||||||
help_text=_("Available placeholders: {event}, {url}, {expire_date}")
|
help_text=_("Available placeholders: {event}, {url}, {expire_date}, {invoice_name}, {invoice_company}")
|
||||||
)
|
)
|
||||||
smtp_use_custom = forms.BooleanField(
|
smtp_use_custom = forms.BooleanField(
|
||||||
label=_("Use custom SMTP server"),
|
label=_("Use custom SMTP server"),
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ from django.views.generic import DetailView, ListView, TemplateView, View
|
|||||||
|
|
||||||
from pretix.base.i18n import language
|
from pretix.base.i18n import language
|
||||||
from pretix.base.models import (
|
from pretix.base.models import (
|
||||||
CachedFile, CachedTicket, Invoice, Item, ItemVariation, Order, Quota,
|
CachedFile, CachedTicket, Invoice, InvoiceAddress, Item, ItemVariation,
|
||||||
generate_position_secret, generate_secret,
|
Order, Quota, generate_position_secret, generate_secret,
|
||||||
)
|
)
|
||||||
from pretix.base.services.export import export
|
from pretix.base.services.export import export
|
||||||
from pretix.base.services.invoices import (
|
from pretix.base.services.invoices import (
|
||||||
@@ -323,6 +323,12 @@ class OrderResendLink(OrderView):
|
|||||||
def post(self, *args, **kwargs):
|
def post(self, *args, **kwargs):
|
||||||
with language(self.order.locale):
|
with language(self.order.locale):
|
||||||
try:
|
try:
|
||||||
|
try:
|
||||||
|
invoice_name = self.order.invoice_address.name
|
||||||
|
invoice_company = self.order.invoice_address.company
|
||||||
|
except InvoiceAddress.DoesNotExist:
|
||||||
|
invoice_name = ""
|
||||||
|
invoice_company = ""
|
||||||
mail(
|
mail(
|
||||||
self.order.email, _('Your order: %(code)s') % {'code': self.order.code},
|
self.order.email, _('Your order: %(code)s') % {'code': self.order.code},
|
||||||
self.order.event.settings.mail_text_resend_link,
|
self.order.event.settings.mail_text_resend_link,
|
||||||
@@ -332,6 +338,8 @@ class OrderResendLink(OrderView):
|
|||||||
'order': self.order.code,
|
'order': self.order.code,
|
||||||
'secret': self.order.secret
|
'secret': self.order.secret
|
||||||
}),
|
}),
|
||||||
|
'invoice_name': invoice_name,
|
||||||
|
'invoice_company': invoice_company,
|
||||||
},
|
},
|
||||||
self.order.event, locale=self.order.locale
|
self.order.event, locale=self.order.locale
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ class MailForm(forms.Form):
|
|||||||
self.fields['message'] = I18nFormField(
|
self.fields['message'] = I18nFormField(
|
||||||
widget=I18nTextarea, required=True,
|
widget=I18nTextarea, required=True,
|
||||||
langcodes=event.settings.get('locales'),
|
langcodes=event.settings.get('locales'),
|
||||||
help_text=_("Available placeholders: {due_date}, {event}, {order}, {order_date}, {order_url}")
|
help_text=_("Available placeholders: {due_date}, {event}, {order}, {order_date}, {order_url}, "
|
||||||
|
"{invoice_name}, {invoice_company}")
|
||||||
)
|
)
|
||||||
choices = list(Order.STATUS_CHOICE)
|
choices = list(Order.STATUS_CHOICE)
|
||||||
if not event.settings.get('payment_term_expire_automatically', as_type=bool):
|
if not event.settings.get('payment_term_expire_automatically', as_type=bool):
|
||||||
|
|||||||
Reference in New Issue
Block a user