forked from CGM_Public/pretix_original
Hotfix for exporters via API (#6007)
* Hotfix for exporters via API * Apply suggestion from @raphaelm
This commit is contained in:
@@ -75,7 +75,8 @@ class JobRunSerializer(serializers.Serializer):
|
|||||||
def to_representation(self, instance):
|
def to_representation(self, instance):
|
||||||
# Translate between events as a list of slugs (API) and list of ints (database)
|
# Translate between events as a list of slugs (API) and list of ints (database)
|
||||||
if self.ex.is_multievent and not isinstance(self.ex, OrganizerLevelExportMixin) and "events" in instance and isinstance(instance["events"], list):
|
if self.ex.is_multievent and not isinstance(self.ex, OrganizerLevelExportMixin) and "events" in instance and isinstance(instance["events"], list):
|
||||||
instance["events"] = [e.slug for e in self.ex.events.filter(pk__in=instance["events"]).only("slug")]
|
instance["events"] = [e for e in self.ex.events.filter(pk__in=instance["events"])]
|
||||||
|
instance = super().to_representation(instance)
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
def to_internal_value(self, data):
|
def to_internal_value(self, data):
|
||||||
|
|||||||
@@ -65,8 +65,9 @@ def form_field_to_serializer_field(field):
|
|||||||
if isinstance(field, m_from):
|
if isinstance(field, m_from):
|
||||||
return m_to(
|
return m_to(
|
||||||
required=field.required,
|
required=field.required,
|
||||||
allow_null=not field.required,
|
allow_null=not field.required and not isinstance(field, forms.BooleanField),
|
||||||
validators=field.validators,
|
validators=field.validators,
|
||||||
|
initial=field.initial,
|
||||||
**{kwarg: getattr(field, kwarg, None) for kwarg in m_kwargs}
|
**{kwarg: getattr(field, kwarg, None) for kwarg in m_kwargs}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -493,6 +493,7 @@ def org_scheduled_export(organizer, user):
|
|||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_org_scheduled_export_list_token(token_client, organizer, user, team, org_scheduled_export):
|
def test_org_scheduled_export_list_token(token_client, organizer, user, team, org_scheduled_export):
|
||||||
res = dict(TEST_SCHEDULED_EXPORT_RES)
|
res = dict(TEST_SCHEDULED_EXPORT_RES)
|
||||||
|
res["export_form_data"]["event_date_range"] = None
|
||||||
res["id"] = org_scheduled_export.pk
|
res["id"] = org_scheduled_export.pk
|
||||||
res["schedule_next_run"] = org_scheduled_export.schedule_next_run.astimezone(zoneinfo.ZoneInfo("UTC")). \
|
res["schedule_next_run"] = org_scheduled_export.schedule_next_run.astimezone(zoneinfo.ZoneInfo("UTC")). \
|
||||||
isoformat().replace("+00:00", "Z")
|
isoformat().replace("+00:00", "Z")
|
||||||
@@ -518,6 +519,7 @@ def test_org_scheduled_export_list_user(user_client, organizer, user, team, org_
|
|||||||
team.members.add(user2)
|
team.members.add(user2)
|
||||||
|
|
||||||
res = dict(TEST_SCHEDULED_EXPORT_RES)
|
res = dict(TEST_SCHEDULED_EXPORT_RES)
|
||||||
|
res["export_form_data"]["event_date_range"] = None
|
||||||
res["id"] = org_scheduled_export.pk
|
res["id"] = org_scheduled_export.pk
|
||||||
res["schedule_next_run"] = org_scheduled_export.schedule_next_run.astimezone(zoneinfo.ZoneInfo("UTC")). \
|
res["schedule_next_run"] = org_scheduled_export.schedule_next_run.astimezone(zoneinfo.ZoneInfo("UTC")). \
|
||||||
isoformat().replace("+00:00", "Z")
|
isoformat().replace("+00:00", "Z")
|
||||||
@@ -545,6 +547,7 @@ def test_org_scheduled_export_list_user(user_client, organizer, user, team, org_
|
|||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_org_scheduled_export_detail(token_client, organizer, user, org_scheduled_export):
|
def test_org_scheduled_export_detail(token_client, organizer, user, org_scheduled_export):
|
||||||
res = dict(TEST_SCHEDULED_EXPORT_RES)
|
res = dict(TEST_SCHEDULED_EXPORT_RES)
|
||||||
|
res["export_form_data"]["event_date_range"] = None
|
||||||
res["id"] = org_scheduled_export.pk
|
res["id"] = org_scheduled_export.pk
|
||||||
res["schedule_next_run"] = org_scheduled_export.schedule_next_run.astimezone(zoneinfo.ZoneInfo("UTC")). \
|
res["schedule_next_run"] = org_scheduled_export.schedule_next_run.astimezone(zoneinfo.ZoneInfo("UTC")). \
|
||||||
isoformat().replace("+00:00", "Z")
|
isoformat().replace("+00:00", "Z")
|
||||||
@@ -959,6 +962,7 @@ def test_organizer_edit_restrictions(client, event, organizer, user, team):
|
|||||||
organizer=organizer,
|
organizer=organizer,
|
||||||
owner=user2,
|
owner=user2,
|
||||||
export_identifier="giftcardlist",
|
export_identifier="giftcardlist",
|
||||||
|
export_form_data={"_format": "xlsx"},
|
||||||
mail_subject="Test",
|
mail_subject="Test",
|
||||||
mail_template="Test",
|
mail_template="Test",
|
||||||
locale="en",
|
locale="en",
|
||||||
|
|||||||
Reference in New Issue
Block a user