(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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user