05/07 Phase 3: fixed staff creation error

This commit is contained in:
2026-05-07 16:00:27 -04:00
parent 61a1b83688
commit 959f54ed84
2 changed files with 16 additions and 19 deletions
+6 -6
View File
@@ -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("/<int:staff_id>/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)