mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Allow to enter a custom text that needs to be confirmed during checkout
This commit is contained in:
@@ -6,6 +6,7 @@ from typing import List, Optional
|
||||
from celery.exceptions import MaxRetriesExceededError
|
||||
from django.db import transaction
|
||||
from django.db.models import Q
|
||||
from django.dispatch import receiver
|
||||
from django.utils.timezone import now
|
||||
from django.utils.translation import pgettext_lazy, ugettext as _
|
||||
|
||||
@@ -19,8 +20,11 @@ from pretix.base.models.tax import TAXED_ZERO, TaxedPrice, TaxRule
|
||||
from pretix.base.services.async import ProfiledTask
|
||||
from pretix.base.services.locking import LockTimeoutException
|
||||
from pretix.base.services.pricing import get_price
|
||||
from pretix.base.templatetags.rich_text import rich_text
|
||||
from pretix.celery_app import app
|
||||
from pretix.presale.signals import fee_calculation_for_cart
|
||||
from pretix.presale.signals import (
|
||||
checkout_confirm_messages, fee_calculation_for_cart,
|
||||
)
|
||||
|
||||
|
||||
class CartError(LazyLocaleException):
|
||||
@@ -761,3 +765,13 @@ def set_cart_addons(self, event: int, addons: List[dict], cart_id: str=None, loc
|
||||
self.retry()
|
||||
except (MaxRetriesExceededError, LockTimeoutException):
|
||||
raise CartError(error_messages['busy'])
|
||||
|
||||
|
||||
@receiver(checkout_confirm_messages, dispatch_uid="cart_confirm_messages")
|
||||
def confirm_messages(sender, *args, **kwargs):
|
||||
if not sender.settings.confirm_text:
|
||||
return {}
|
||||
|
||||
return {
|
||||
'confirm_text': rich_text(str(sender.settings.confirm_text))
|
||||
}
|
||||
|
||||
@@ -209,6 +209,10 @@ DEFAULTS = {
|
||||
'default': None,
|
||||
'type': str
|
||||
},
|
||||
'confirm_text': {
|
||||
'default': None,
|
||||
'type': str
|
||||
},
|
||||
'mail_prefix': {
|
||||
'default': None,
|
||||
'type': str
|
||||
|
||||
@@ -339,6 +339,13 @@ class EventSettingsForm(SettingsForm):
|
||||
label=_("Imprint URL"),
|
||||
required=False,
|
||||
)
|
||||
confirm_text = forms.CharField(
|
||||
label=_('Confirmation text'),
|
||||
help_text=_('This text needs to be confirmed by the user before a purchase is possible. You could for example '
|
||||
'link your terms of service here. If you use the Pages feature to publish your terms of service, '
|
||||
'you don\'t need this setting since you can configure it there.'),
|
||||
widget=forms.Textarea(attrs={"rows": 3})
|
||||
)
|
||||
contact_mail = forms.EmailField(
|
||||
label=_("Contact address"),
|
||||
required=False,
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
{% bootstrap_field sform.show_times layout="horizontal" %}
|
||||
{% bootstrap_field sform.contact_mail layout="horizontal" %}
|
||||
{% bootstrap_field sform.imprint_url layout="horizontal" %}
|
||||
{% bootstrap_field sform.confirm_text layout="horizontal" %}
|
||||
{% bootstrap_field sform.show_quota_left layout="horizontal" %}
|
||||
{% bootstrap_field sform.display_net_prices layout="horizontal" %}
|
||||
</fieldset>
|
||||
|
||||
Reference in New Issue
Block a user