mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Fix order-level exports through the API
This commit is contained in:
@@ -23,6 +23,8 @@ from django import forms
|
||||
from django.http import QueryDict
|
||||
from rest_framework import serializers
|
||||
|
||||
from pretix.base.exporter import OrganizerLevelExportMixin
|
||||
|
||||
|
||||
class FormFieldWrapperField(serializers.Field):
|
||||
def __init__(self, *args, **kwargs):
|
||||
@@ -87,7 +89,7 @@ class JobRunSerializer(serializers.Serializer):
|
||||
ex = kwargs.pop('exporter')
|
||||
events = kwargs.pop('events', None)
|
||||
super().__init__(*args, **kwargs)
|
||||
if events is not None:
|
||||
if events is not None and not isinstance(ex, OrganizerLevelExportMixin):
|
||||
self.fields["events"] = serializers.SlugRelatedField(
|
||||
queryset=events,
|
||||
required=True,
|
||||
|
||||
@@ -196,6 +196,7 @@ def test_gone_without_celery(token_client, organizer, team, event):
|
||||
@pytest.mark.django_db
|
||||
def test_org_level_export(token_client, organizer, team, event):
|
||||
resp = token_client.post('/api/v1/organizers/{}/exporters/giftcardlist/run/'.format(organizer.slug), data={
|
||||
'date': '2022-10-05T00:00:00Z',
|
||||
'_format': 'xlsx',
|
||||
}, format='json')
|
||||
assert resp.status_code == 202
|
||||
@@ -204,6 +205,7 @@ def test_org_level_export(token_client, organizer, team, event):
|
||||
team.save()
|
||||
|
||||
resp = token_client.post('/api/v1/organizers/{}/exporters/giftcardlist/run/'.format(organizer.slug), data={
|
||||
'date': '2022-10-05T00:00:00Z',
|
||||
'_format': 'xlsx',
|
||||
}, format='json')
|
||||
assert resp.status_code == 404
|
||||
|
||||
Reference in New Issue
Block a user