Hotfix for exporters via API (#6007)

* Hotfix for exporters via API

* Apply suggestion from @raphaelm
This commit is contained in:
Raphael Michel
2026-03-18 15:50:05 +01:00
committed by GitHub
parent e1b8e16a34
commit 58840a5fd6
3 changed files with 8 additions and 2 deletions

View File

@@ -75,7 +75,8 @@ class JobRunSerializer(serializers.Serializer):
def to_representation(self, instance):
# 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):
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
def to_internal_value(self, data):

View File

@@ -65,8 +65,9 @@ def form_field_to_serializer_field(field):
if isinstance(field, m_from):
return m_to(
required=field.required,
allow_null=not field.required,
allow_null=not field.required and not isinstance(field, forms.BooleanField),
validators=field.validators,
initial=field.initial,
**{kwarg: getattr(field, kwarg, None) for kwarg in m_kwargs}
)

View File

@@ -493,6 +493,7 @@ def org_scheduled_export(organizer, user):
@pytest.mark.django_db
def test_org_scheduled_export_list_token(token_client, organizer, user, team, org_scheduled_export):
res = dict(TEST_SCHEDULED_EXPORT_RES)
res["export_form_data"]["event_date_range"] = None
res["id"] = org_scheduled_export.pk
res["schedule_next_run"] = org_scheduled_export.schedule_next_run.astimezone(zoneinfo.ZoneInfo("UTC")). \
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)
res = dict(TEST_SCHEDULED_EXPORT_RES)
res["export_form_data"]["event_date_range"] = None
res["id"] = org_scheduled_export.pk
res["schedule_next_run"] = org_scheduled_export.schedule_next_run.astimezone(zoneinfo.ZoneInfo("UTC")). \
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
def test_org_scheduled_export_detail(token_client, organizer, user, org_scheduled_export):
res = dict(TEST_SCHEDULED_EXPORT_RES)
res["export_form_data"]["event_date_range"] = None
res["id"] = org_scheduled_export.pk
res["schedule_next_run"] = org_scheduled_export.schedule_next_run.astimezone(zoneinfo.ZoneInfo("UTC")). \
isoformat().replace("+00:00", "Z")
@@ -959,6 +962,7 @@ def test_organizer_edit_restrictions(client, event, organizer, user, team):
organizer=organizer,
owner=user2,
export_identifier="giftcardlist",
export_form_data={"_format": "xlsx"},
mail_subject="Test",
mail_template="Test",
locale="en",