mirror of
https://github.com/pretix/pretix.git
synced 2026-05-08 15:44:02 +00:00
Add field length validation for invoice settings (Z#23215182) (#5639)
Limit invoice settings field lengths, add min value for counter length
This commit is contained in:
@@ -690,6 +690,7 @@ DEFAULTS = {
|
|||||||
label=_("Minimum length of invoice number after prefix"),
|
label=_("Minimum length of invoice number after prefix"),
|
||||||
help_text=_("The part of your invoice number after your prefix will be filled up with leading zeros up to this length, e.g. INV-001 or INV-00001."),
|
help_text=_("The part of your invoice number after your prefix will be filled up with leading zeros up to this length, e.g. INV-001 or INV-00001."),
|
||||||
max_value=12,
|
max_value=12,
|
||||||
|
min_value=1,
|
||||||
required=True,
|
required=True,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
@@ -725,8 +726,9 @@ DEFAULTS = {
|
|||||||
message=lazy(lambda *args: _('Please only use the characters {allowed} in this field.').format(
|
message=lazy(lambda *args: _('Please only use the characters {allowed} in this field.').format(
|
||||||
allowed='A-Z, a-z, 0-9, -./:#'
|
allowed='A-Z, a-z, 0-9, -./:#'
|
||||||
), str)()
|
), str)()
|
||||||
)
|
),
|
||||||
],
|
],
|
||||||
|
max_length=155,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
'invoice_numbers_prefix_cancellations': {
|
'invoice_numbers_prefix_cancellations': {
|
||||||
@@ -747,8 +749,9 @@ DEFAULTS = {
|
|||||||
message=lazy(lambda *args: _('Please only use the characters {allowed} in this field.').format(
|
message=lazy(lambda *args: _('Please only use the characters {allowed} in this field.').format(
|
||||||
allowed='A-Z, a-z, 0-9, -./:#'
|
allowed='A-Z, a-z, 0-9, -./:#'
|
||||||
), str)()
|
), str)()
|
||||||
)
|
),
|
||||||
],
|
],
|
||||||
|
max_length=155,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
'invoice_renderer_highlight_order_code': {
|
'invoice_renderer_highlight_order_code': {
|
||||||
@@ -1203,6 +1206,7 @@ DEFAULTS = {
|
|||||||
'form_class': forms.CharField,
|
'form_class': forms.CharField,
|
||||||
'serializer_class': serializers.CharField,
|
'serializer_class': serializers.CharField,
|
||||||
'form_kwargs': dict(
|
'form_kwargs': dict(
|
||||||
|
max_length=190,
|
||||||
label=_("Company name"),
|
label=_("Company name"),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
@@ -1216,6 +1220,7 @@ DEFAULTS = {
|
|||||||
'placeholder': '12345'
|
'placeholder': '12345'
|
||||||
}),
|
}),
|
||||||
label=_("ZIP code"),
|
label=_("ZIP code"),
|
||||||
|
max_length=190,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
'invoice_address_from_city': {
|
'invoice_address_from_city': {
|
||||||
@@ -1228,6 +1233,7 @@ DEFAULTS = {
|
|||||||
'placeholder': _('Random City')
|
'placeholder': _('Random City')
|
||||||
}),
|
}),
|
||||||
label=_("City"),
|
label=_("City"),
|
||||||
|
max_length=190,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
'invoice_address_from_state': {
|
'invoice_address_from_state': {
|
||||||
@@ -1264,7 +1270,8 @@ DEFAULTS = {
|
|||||||
'serializer_class': serializers.CharField,
|
'serializer_class': serializers.CharField,
|
||||||
'form_kwargs': dict(
|
'form_kwargs': dict(
|
||||||
label=_("Domestic tax ID"),
|
label=_("Domestic tax ID"),
|
||||||
help_text=_("e.g. tax number in Germany, ABN in Australia, …")
|
help_text=_("e.g. tax number in Germany, ABN in Australia, …"),
|
||||||
|
max_length=190,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
'invoice_address_from_vat_id': {
|
'invoice_address_from_vat_id': {
|
||||||
@@ -1274,6 +1281,7 @@ DEFAULTS = {
|
|||||||
'serializer_class': serializers.CharField,
|
'serializer_class': serializers.CharField,
|
||||||
'form_kwargs': dict(
|
'form_kwargs': dict(
|
||||||
label=_("EU VAT ID"),
|
label=_("EU VAT ID"),
|
||||||
|
max_length=190,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
'invoice_introductory_text': {
|
'invoice_introductory_text': {
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ import pycountry
|
|||||||
from django import forms
|
from django import forms
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.exceptions import NON_FIELD_ERRORS, ValidationError
|
from django.core.exceptions import NON_FIELD_ERRORS, ValidationError
|
||||||
from django.core.validators import MaxValueValidator
|
|
||||||
from django.db.models import Prefetch, Q, prefetch_related_objects
|
from django.db.models import Prefetch, Q, prefetch_related_objects
|
||||||
from django.forms import formset_factory, inlineformset_factory
|
from django.forms import formset_factory, inlineformset_factory
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
@@ -1000,8 +999,6 @@ class InvoiceSettingsForm(EventSettingsValidationMixin, SettingsForm):
|
|||||||
self.fields['invoice_generate_sales_channels'].choices = (
|
self.fields['invoice_generate_sales_channels'].choices = (
|
||||||
(c.identifier, c.label) for c in event.organizer.sales_channels.all()
|
(c.identifier, c.label) for c in event.organizer.sales_channels.all()
|
||||||
)
|
)
|
||||||
self.fields['invoice_numbers_counter_length'].validators.append(MaxValueValidator(15))
|
|
||||||
|
|
||||||
pps = [str(pp.verbose_name) for pp in event.get_payment_providers().values() if pp.requires_invoice_immediately]
|
pps = [str(pp.verbose_name) for pp in event.get_payment_providers().values() if pp.requires_invoice_immediately]
|
||||||
if pps:
|
if pps:
|
||||||
generate_paid_help_text = _('An invoice will be issued before payment if the customer selects one of the following payment methods: {list}').format(
|
generate_paid_help_text = _('An invoice will be issued before payment if the customer selects one of the following payment methods: {list}').format(
|
||||||
|
|||||||
Reference in New Issue
Block a user