mirror of
https://github.com/pretix/pretix.git
synced 2026-08-06 10:07:50 +00:00
Add typeahead suggestions for voucher tag field (#6058)
Suggest existing tags as the user types in the voucher tag field. Waiting list voucher tags are excluded from suggestions.
This commit is contained in:
@@ -44,7 +44,7 @@ from tests.base import SoupTestMixin, extract_form_fields
|
||||
|
||||
from pretix.base.models import (
|
||||
Event, Item, ItemVariation, Order, OrderPosition, Organizer, Quota, Team,
|
||||
User, Voucher,
|
||||
User, Voucher, WaitingListEntry,
|
||||
)
|
||||
|
||||
|
||||
@@ -771,3 +771,38 @@ class VoucherFormTest(SoupTestMixin, TransactionTestCase):
|
||||
|
||||
assert len(doc.select('.alert-warning ul li')) == 1 # Check that there's exactly 1 item in the warning list
|
||||
assert doc.text.count('Order DEDUP') == 1 # Check that the order is listed exactly once
|
||||
|
||||
def test_tag_typeahead(self):
|
||||
with scopes_disabled():
|
||||
self.event.vouchers.create(item=self.ticket, code='AAAAAAA', tag='early-bird')
|
||||
self.event.vouchers.create(item=self.ticket, code='BBBBBBB', tag='early-vip')
|
||||
self.event.vouchers.create(item=self.ticket, code='CCCCCCC', tag='sponsor')
|
||||
|
||||
url = '/control/event/%s/%s/vouchers/tags/typeahead' % (self.orga.slug, self.event.slug)
|
||||
resp = self.client.get(url + '?q=early')
|
||||
|
||||
assert resp.status_code == 200
|
||||
data = json.loads(resp.content.decode())
|
||||
names = [r['name'] for r in data['results']]
|
||||
|
||||
assert 'early-bird' in names
|
||||
assert 'early-vip' in names
|
||||
assert 'sponsor' not in names
|
||||
|
||||
def test_tag_typeahead_excludes_waiting_list(self):
|
||||
with scopes_disabled():
|
||||
v = self.event.vouchers.create(item=self.ticket, code='AAAAAAA', tag='waiting-list')
|
||||
WaitingListEntry.objects.create(
|
||||
event=self.event, item=self.ticket, email='foo@example.com', voucher=v
|
||||
)
|
||||
self.event.vouchers.create(item=self.ticket, code='BBBBBBB', tag='walk-ins')
|
||||
|
||||
url = '/control/event/%s/%s/vouchers/tags/typeahead' % (self.orga.slug, self.event.slug)
|
||||
resp = self.client.get(url + '?q=wa')
|
||||
|
||||
assert resp.status_code == 200
|
||||
data = json.loads(resp.content.decode())
|
||||
names = [r['name'] for r in data['results']]
|
||||
|
||||
assert 'walk-ins' in names
|
||||
assert 'waiting-list' not in names
|
||||
|
||||
Reference in New Issue
Block a user