forked from CGM_Public/pretix_original
* Data model draft * Refactor query and assignment usages of old permissions * Backend UI * API serializer * Big string replace * Docs, tests and fixes for teams api * Update docs for device auth * Eliminate old names * Make tests pass * Use new permissions, remove inconsistencies * Add test for translations * Show plugin permissions * Add permission for seating plans * Fix plugin activation * Fix failing test * Refactor to permission groups * Update doc/api/resources/devices.rst Co-authored-by: luelista <weller@rami.io> * Update doc/api/resources/events.rst Co-authored-by: luelista <weller@rami.io> * Update src/pretix/api/serializers/organizer.py Co-authored-by: luelista <weller@rami.io> * Fix typo * Fix python version compat * Replacement after rebase * Add proper permission handling for exports * Docs for exporters * Runtime linting of permission names * Fix typos * Show export page even without orders permission * More legacy compat * Do not strongly validate before plugins are loaded * Rebase migration * Add permission for outgoing mails * Review notes * Update doc/api/resources/teams.rst Co-authored-by: Richard Schreiber <schreiber@pretix.eu> * Clean up logic around exporters * Review and failures * Fix migration leading to forbidden combination * Handle permissions on event copying * Remove print-statements * Make test clearer * Review feedback * Add AnyPermissionOf * migration safety --------- Co-authored-by: luelista <weller@rami.io> Co-authored-by: Richard Schreiber <schreiber@pretix.eu>
88 lines
3.3 KiB
Python
88 lines
3.3 KiB
Python
#
|
|
# This file is part of pretix (Community Edition).
|
|
#
|
|
# Copyright (C) 2014-2020 Raphael Michel and contributors
|
|
# Copyright (C) 2020-today pretix GmbH and contributors
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General
|
|
# Public License as published by the Free Software Foundation in version 3 of the License.
|
|
#
|
|
# ADDITIONAL TERMS APPLY: Pursuant to Section 7 of the GNU Affero General Public License, additional terms are
|
|
# applicable granting you additional permissions and placing additional restrictions on your usage of this software.
|
|
# Please refer to the pretix LICENSE file to obtain the full terms applicable to this work. If you did not receive
|
|
# this file, see <https://pretix.eu/about/en/license>.
|
|
#
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
# details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
|
|
# <https://www.gnu.org/licenses/>.
|
|
#
|
|
import pytest
|
|
from bs4 import BeautifulSoup
|
|
from django.core.files.uploadedfile import SimpleUploadedFile
|
|
from django.utils.timezone import now
|
|
|
|
from pretix.base.models import Event, Organizer, Team, User
|
|
|
|
|
|
@pytest.fixture
|
|
def env():
|
|
o = Organizer.objects.create(name='Dummy', slug='dummy')
|
|
event = Event.objects.create(
|
|
organizer=o, name='Dummy', slug='dummy',
|
|
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, all_event_permissions=True)
|
|
t.members.add(user)
|
|
t.limit_events.add(event)
|
|
return event, user
|
|
|
|
|
|
@pytest.mark.django_db
|
|
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
|
|
|
|
file = SimpleUploadedFile('file.csv', """First name,Last name,Email
|
|
Dieter,Schneider,schneider@example.org
|
|
Daniel,Wulf,daniel@example.org
|
|
Daniel,Wulf,daniel@example.org
|
|
Anke,Müller,anke@example.net
|
|
|
|
""".encode("utf-8"), content_type="text/csv")
|
|
|
|
r = client.post('/control/event/dummy/dummy/orders/import/', {
|
|
'file': file
|
|
}, follow=True)
|
|
print(r.content)
|
|
doc = BeautifulSoup(r.content, "lxml")
|
|
assert doc.select("input[name=orders]")
|
|
assert doc.select("input[name=status]")
|
|
assert doc.select("select[name=attendee_email]")
|
|
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
|