refactor(wizard): use dynamic cadence validation

Update wizard POST handler to use the same dynamic cadence validation
pattern as the adapter edit form:
- Use AdapterConfig.model_fields["cadence_s"].metadata[0].ge for min bound
- Remove hardcoded 60-3600 range check
- Remove min/max attributes from setup_adapters.html template

No tests in test_wizard.py referenced the old cadence range.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Matt Johnson 2026-05-19 00:14:33 +00:00
commit d42b540e16
2 changed files with 8 additions and 4 deletions

View file

@ -763,12 +763,16 @@ async def setup_adapters_submit(request: Request) -> Response:
# Parse enabled
enabled = f"{adapter_name}_enabled" in form
# Parse cadence
# Parse cadence using AdapterConfig field constraint
cadence_str = form.get(f"{adapter_name}_cadence_s", "")
try:
cadence_s = int(cadence_str)
if cadence_s < 60 or cadence_s > 3600:
errors[f"{adapter_name}_cadence_s"] = "Cadence must be between 60 and 3600 seconds"
from central.config_models import AdapterConfig
min_cadence = AdapterConfig.model_fields["cadence_s"].metadata[0].ge
if cadence_s < min_cadence:
errors[f"{adapter_name}_cadence_s"] = (
f"Input should be greater than or equal to {min_cadence}"
)
except ValueError:
errors[f"{adapter_name}_cadence_s"] = "Cadence must be a valid integer"
cadence_s = current.get("cadence_s", 300)