Owner settings: add a real delete for Mitarbeiter (barbers)
Test backoffice (smb-crm) / test (push) Successful in 1m40s
Test backoffice (smb-crm) / test (push) Successful in 1m40s
Rename + active-toggle already existed (this session, earlier commit) -- this adds a genuine, permanent delete alongside them, guarded by a confirm() prompt that points to the "Aktiv" checkbox as the reversible alternative for someone just temporarily off. Existing bookings against a deleted resource are left as-is (no FK in this schema, matching its existing convention) -- the owner agenda already falls back to the raw resource_id for a booking whose resource no longer resolves, same as it does today for a deactivated one. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -183,6 +183,27 @@ def update_resource(client_id, resource_id, **fields):
|
||||
return row
|
||||
|
||||
|
||||
def delete_resource(client_id, resource_id):
|
||||
"""Permanently remove a resource (and its resource_hours), scoped to
|
||||
client_id. Returns resource_id on success, None if no such resource
|
||||
exists for this client. Existing bookings against this resource_id are
|
||||
left as-is (no FK, matching this schema's convention) -- the owner
|
||||
agenda already falls back to showing the raw resource_id in place of a
|
||||
name for a booking whose resource no longer resolves (see
|
||||
owner_booking.py's _agenda_days), same as it does for a deactivated one."""
|
||||
with db.connect() as conn, conn.cursor() as cur:
|
||||
cur.execute(
|
||||
"DELETE FROM resources WHERE client_id = %s AND resource_id = %s RETURNING resource_id",
|
||||
(client_id, resource_id))
|
||||
row = cur.fetchone()
|
||||
if row is None:
|
||||
conn.commit()
|
||||
return None
|
||||
cur.execute("DELETE FROM resource_hours WHERE resource_id = %s", (resource_id,))
|
||||
conn.commit()
|
||||
return row["resource_id"]
|
||||
|
||||
|
||||
def get_resource_hours(client_id, resource_id):
|
||||
"""Return {weekday: (opens_at, closes_at)} for client_id's own resource
|
||||
(empty for a resource with no hours configured yet, or one that isn't
|
||||
|
||||
Reference in New Issue
Block a user