(bugfix) Preserve existing schedule values in the edit form

Only apply default schedule initial values when creating a new schedule.

Avoid passing default initial data while editing an existing ScheduleConfig,
so the form renders the active cron-style expression, user, and retention
settings from the database.

Add a regression test that reopens an existing schedule and verifies the
stored values are shown instead of defaults.
This commit is contained in:
2026-05-19 23:13:53 +02:00
parent 39b6cf3469
commit 1e04da9de8
2 changed files with 25 additions and 1 deletions

View File

@@ -535,7 +535,11 @@ def edit_host_schedule(request, host: str):
messages.success(request, f"Schedule saved for {host_config.host}.")
return redirect("host_detail", host=host_config.host)
else:
form = ScheduleConfigForm(instance=schedule, initial=_default_schedule_initial())
form = (
ScheduleConfigForm(instance=schedule)
if schedule
else ScheduleConfigForm(initial=_default_schedule_initial())
)
return render(
request,