mirror of
https://github.com/pretix/pretix.git
synced 2026-08-15 11:36:27 +00:00
Voucher import: Fix quota name check
This commit is contained in:
@@ -251,7 +251,7 @@ class QuotaColumn(ImportColumn):
|
||||
raise ValidationError(_("You cannot specify a quota if you specified a product."))
|
||||
matches = [
|
||||
q for q in self.quotas
|
||||
if str(q.pk) == value or any((v and v == value) for v in i18n_flat(q.name))
|
||||
if str(q.pk) == value or q.name == value
|
||||
]
|
||||
if len(matches) == 0:
|
||||
raise ValidationError(_("No matching variation was found."))
|
||||
|
||||
@@ -180,3 +180,18 @@ def test_price_mode_validation(event, item, user):
|
||||
v = event.vouchers.get(code="ABCDE123")
|
||||
assert v.price_mode == "percent"
|
||||
assert v.value == Decimal("1.00")
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@scopes_disabled()
|
||||
def test_quota(event, item, user):
|
||||
settings = dict(DEFAULT_SETTINGS)
|
||||
settings['quota'] = 'csv:B'
|
||||
settings['item'] = 'empty'
|
||||
q = event.quotas.create(name="Ticket", size=100)
|
||||
import_vouchers.apply(
|
||||
args=(event.pk, inputfile_factory().id, settings, 'en', user.pk)
|
||||
).get()
|
||||
assert event.vouchers.count() == 2
|
||||
v = event.vouchers.get(code="ABCDE123")
|
||||
assert v.quota == q
|
||||
|
||||
Reference in New Issue
Block a user