(feature) Add host config editing view
Add a staff-only Django form for editing operational host settings while keeping host identity stable. Support address, enablement, SSH/source overrides, include/exclude lists, rsync extra args, and retention settings using the same SQL-backed HostConfig model consumed by backup and scheduler flows. Parse newline-separated list fields into JSON lists, preserve nullable excludes_replace semantics, and cover rendering plus update behavior with view tests.
This commit is contained in:
@@ -8,7 +8,7 @@ from django.views.decorators.http import require_POST
|
||||
|
||||
from pobsync.errors import ConfigError
|
||||
|
||||
from .forms import ScheduleConfigForm
|
||||
from .forms import HostConfigForm, ScheduleConfigForm
|
||||
from .models import BackupRun, HostConfig, ScheduleConfig, SnapshotRecord
|
||||
from .retention import run_sql_retention_plan
|
||||
from .snapshot_discovery import discover_snapshots
|
||||
@@ -96,6 +96,28 @@ def host_retention_plan(request, host: str):
|
||||
return render(request, "pobsync_backend/retention_plan.html", context)
|
||||
|
||||
|
||||
@staff_member_required
|
||||
def edit_host_config(request, host: str):
|
||||
host_config = get_object_or_404(HostConfig, host=host)
|
||||
if request.method == "POST":
|
||||
form = HostConfigForm(request.POST, instance=host_config)
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
messages.success(request, f"Host config saved for {host_config.host}.")
|
||||
return redirect("host_detail", host=host_config.host)
|
||||
else:
|
||||
form = HostConfigForm(instance=host_config)
|
||||
|
||||
return render(
|
||||
request,
|
||||
"pobsync_backend/host_form.html",
|
||||
{
|
||||
"host": host_config,
|
||||
"form": form,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@staff_member_required
|
||||
def edit_host_schedule(request, host: str):
|
||||
host_config = get_object_or_404(HostConfig, host=host)
|
||||
|
||||
Reference in New Issue
Block a user