From 959f54ed848302cf07269bf99f810341a81d57eb Mon Sep 17 00:00:00 2001 From: NguyenND Date: Thu, 7 May 2026 16:00:27 -0400 Subject: [PATCH] 05/07 Phase 3: fixed staff creation error --- app/tenant/staff/routes.py | 12 ++++++------ templates/tenant/staff/form.html | 23 ++++++++++------------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/app/tenant/staff/routes.py b/app/tenant/staff/routes.py index 37fd51e..ddfa6f1 100644 --- a/app/tenant/staff/routes.py +++ b/app/tenant/staff/routes.py @@ -48,21 +48,21 @@ def create(): max_len = 6 if not name or not phone: return render_template("tenant/staff/form.html", mode="create", - locations=locations, error="Name and phone are required.") + locations=locations, assigned_ids=set(), error="Name and phone are required.") if not validate_passcode(passcode, min_len, max_len): return render_template("tenant/staff/form.html", mode="create", - locations=locations, + locations=locations, assigned_ids=set(), error=f"Passcode must be {min_len}–{max_len} digits.") if Staff.query.filter_by(tenant_id=g.tenant.id, phone=phone).filter( Staff.deleted_at.is_(None)).first(): return render_template("tenant/staff/form.html", mode="create", - locations=locations, + locations=locations, assigned_ids=set(), error="A staff member with that phone number already exists.") allowed, err = plan_limit_check("staff") if not allowed: return render_template("tenant/staff/form.html", mode="create", - locations=locations, error=err) + locations=locations, assigned_ids=set(), error=err) member = Staff( tenant_id=g.tenant.id, name=name, phone=phone, @@ -96,7 +96,7 @@ def create(): flash(f"Staff member \'{name}\' created.", "success") return redirect(url_for("staff.index")) - return render_template("tenant/staff/form.html", mode="create", locations=locations) + return render_template("tenant/staff/form.html", mode="create", locations=locations, assigned_ids=set()) @staff_bp.route("//edit", methods=["GET", "POST"]) @@ -192,4 +192,4 @@ def reset_passcode(staff_id): "success") return redirect(url_for("staff.index")) - return render_template("tenant/staff/reset_passcode.html", staff=member) + return render_template("tenant/staff/reset_passcode.html", staff=member) \ No newline at end of file diff --git a/templates/tenant/staff/form.html b/templates/tenant/staff/form.html index 8db6496..644ffda 100644 --- a/templates/tenant/staff/form.html +++ b/templates/tenant/staff/form.html @@ -11,19 +11,17 @@
- +
- +
{% if mode == 'create' %}
- +
Staff will use this PIN to log in. Show it to them once, then discard it.
{% endif %} @@ -32,7 +30,7 @@ {% for t in ['hourly','salary','guarantee'] %} - + {% endfor %} @@ -51,17 +49,16 @@ {% for loc in locations %}
- +
{% endfor %} {% if mode == 'edit' %}
- +
{% endif %}