mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Generalize import process from orders to more models (#4002)
* Generalize import process from orders to more models * Add voucher import * Model import: Guess assignments of based on column headers * Fix lock_seats being pointless * Update docs * Update doc/development/api/import.rst Co-authored-by: Richard Schreiber <schreiber@rami.io> * Update src/pretix/base/modelimport_vouchers.py Co-authored-by: Richard Schreiber <schreiber@rami.io> --------- Co-authored-by: Richard Schreiber <schreiber@rami.io>
This commit is contained in:
@@ -35,14 +35,15 @@ def env():
|
||||
date_from=now(), plugins='pretix.plugins.banktransfer,pretix.plugins.paypal'
|
||||
)
|
||||
user = User.objects.create_user('dummy@dummy.dummy', 'dummy')
|
||||
t = Team.objects.create(organizer=event.organizer, can_view_orders=True, can_change_orders=True)
|
||||
t = Team.objects.create(organizer=event.organizer, can_view_orders=True, can_change_orders=True,
|
||||
can_change_vouchers=True)
|
||||
t.members.add(user)
|
||||
t.limit_events.add(event)
|
||||
return event, user
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_import_csv_file(client, env):
|
||||
def test_orders_import_csv_file(client, env):
|
||||
client.login(email='dummy@dummy.dummy', password='dummy')
|
||||
r = client.get('/control/event/dummy/dummy/orders/import/')
|
||||
assert r.status_code == 200
|
||||
@@ -65,3 +66,22 @@ Anke,Müller,anke@example.net
|
||||
assert b"Dieter" in r.content
|
||||
assert b"daniel@example.org" in r.content
|
||||
assert b"Anke" not in r.content
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_vouchers_import_csv_file(client, env):
|
||||
client.login(email='dummy@dummy.dummy', password='dummy')
|
||||
r = client.get('/control/event/dummy/dummy/vouchers/import/')
|
||||
assert r.status_code == 200
|
||||
|
||||
file = SimpleUploadedFile('file.csv', """Code,Product
|
||||
ABC123,Ticket
|
||||
|
||||
""".encode("utf-8"), content_type="text/csv")
|
||||
|
||||
r = client.post('/control/event/dummy/dummy/vouchers/import/', {
|
||||
'file': file
|
||||
}, follow=True)
|
||||
doc = BeautifulSoup(r.content, "lxml")
|
||||
assert doc.select("select[name=code]")
|
||||
assert b"ABC123" in r.content
|
||||
Reference in New Issue
Block a user