Scheduled exports: Fix missing event context, fix form initial

This commit is contained in:
Raphael Michel
2023-01-23 11:31:35 +01:00
parent fdc15a753c
commit 988188b00a
3 changed files with 19 additions and 0 deletions

View File

@@ -245,6 +245,7 @@ def _run_scheduled_export(schedule, context: Union[Event, Organizer], exporter,
subject=schedule.mail_subject,
template=LazyI18nString(schedule.mail_template),
context=get_email_context(event=context) if isinstance(context, Event) else {},
event=context if isinstance(context, Event) else None,
organizer=context.organizer if isinstance(context, Event) else context,
locale=schedule.locale,
attach_cached_files=[file],

View File

@@ -2256,6 +2256,15 @@ class ExportMixin:
if self.scheduled:
initial = self.scheduled.export_form_data
test_form = ExporterForm(data=self.request.GET, prefix=ex.identifier)
test_form.fields = ex.export_form_fields
for k in initial:
if initial[k] and k in test_form.fields:
try:
initial[k] = test_form.fields[k].to_python(initial[k])
except Exception:
pass
else:
# Use form parse cycle to generate useful defaults
test_form = ExporterForm(data=self.request.GET, prefix=ex.identifier)

View File

@@ -1526,6 +1526,15 @@ class ExportMixin:
continue
if self.scheduled:
initial = self.scheduled.export_form_data
test_form = ExporterForm(data=self.request.GET, prefix=ex.identifier)
test_form.fields = ex.export_form_fields
for k in initial:
if initial[k] and k in test_form.fields:
try:
initial[k] = test_form.fields[k].to_python(initial[k])
except Exception:
pass
else:
# Use form parse cycle to generate useful defaults
test_form = ExporterForm(data=self.request.GET, prefix=ex.identifier)