View and edit the rota's `options` used by the builder. Click Edit to open a modal editor.
-
-
-
-
- {% include 'rota/partials/rota_options_display.html' %}
-
+
Configure rota constraint options (typed via RotaConstraintOptions) and a few builder args. Change values and click Save to persist.
+
+ {% if options_form %}
+
+ {% else %}
+
Constraint form unavailable.
+ {% endif %}
+
Available constraint keys
@@ -86,7 +108,6 @@
{{ info.current|default:"" }}
{{ info.description|default:"" }}
- {% comment %} Quick action: add default value if none set {% endcomment %}
{% if info.current is None or info.current == "" %}
diff --git a/djangorota/rota/views.py b/djangorota/rota/views.py
index 28ed0a6..c347a60 100644
--- a/djangorota/rota/views.py
+++ b/djangorota/rota/views.py
@@ -5,7 +5,6 @@ from .models import RotaSchedule, Worker
from .forms import WorkerForm, LeaveForm, RotaScheduleForm
from .services import run_rota_async
from .forms import ShiftForm
-from .forms import RotaOptionsForm
import json
from django.views.decorators.http import require_http_methods
from django.template.loader import render_to_string
@@ -22,8 +21,7 @@ def index(request):
def rota_detail(request, rota_id):
rota = get_object_or_404(RotaSchedule, pk=rota_id)
- # Prepare options form and available builder constraint defaults
- options_form = RotaOptionsForm()
+ # Prepare available builder constraint defaults
available_constraints = {}
try:
# Try to import RotaBuilder to surface its default constraint options
@@ -46,12 +44,6 @@ def rota_detail(request, rota_id):
run = run_rota_async(rota.id, generate_builder=generate_builder, builder_solve=builder_solve)
return redirect(reverse("rota:rota_run_detail", args=(run.id,)))
- # Prefill options form with existing rota.options JSON
- try:
- opt_json = json.dumps(rota.options or {}, indent=4)
- except Exception:
- opt_json = "{}"
-
# Build a richer representation of available constraints (default, type, description)
available_constraints_rich = {}
try:
@@ -87,11 +79,21 @@ def rota_detail(request, rota_id):
except Exception:
available_constraints_rich = {k: {"default": v} for k, v in available_constraints.items()}
- options_form = RotaOptionsForm(initial={"options_json": opt_json})
+ # legacy RotaOptionsForm not used here; we provide a typed RotaScheduleForm below
+
+ # Provide a typed RotaScheduleForm instance so the template can render
+ # the constraint fields (prefixed with `opt__`) inline and submit them
+ # to the existing `rota_options` view which understands typed forms.
+ from .forms import RotaScheduleForm
+ try:
+ typed_form = RotaScheduleForm(instance=rota)
+ except Exception:
+ typed_form = None
+
return render(
request,
"rota/rota_detail.html",
- {"rota": rota, "options_form": options_form, "available_constraints": available_constraints_rich},
+ {"rota": rota, "options_form": typed_form, "available_constraints": available_constraints_rich},
)