feat: add delete customer + fix auth form UX
- Backend: DELETE /api/customers/:id removes customer + extensions + logs - Frontend: delete button on customer detail with confirmation - Auth form: only sends espocrm_api_key when credentials are entered Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -492,6 +492,9 @@ class APIHandler(BaseHTTPRequestHandler):
|
||||
if re.match(r'/api/customers/\d+/extensions/\d+$', path):
|
||||
m = re.search(r'/api/customers/(\d+)/extensions/(\d+)', path)
|
||||
self._remove_extension(int(m.group(1)), int(m.group(2)))
|
||||
elif re.match(r'/api/customers/\d+$', path):
|
||||
cid = int(re.search(r'/api/customers/(\d+)', path).group(1))
|
||||
self._delete_customer(cid)
|
||||
else:
|
||||
self._respond(404, {'error': 'Not found'})
|
||||
|
||||
@@ -560,6 +563,12 @@ class APIHandler(BaseHTTPRequestHandler):
|
||||
(cid, body['extension_id'], body.get('auto_update', True), body.get('license_status', 'active')), fetch=None)
|
||||
self._respond(201, {'status': 'ok'})
|
||||
|
||||
def _delete_customer(self, cid):
|
||||
query("DELETE FROM customer_extensions WHERE customer_id = %s", (cid,), fetch=None)
|
||||
query("DELETE FROM deployment_log WHERE customer_id = %s", (cid,), fetch=None)
|
||||
query("DELETE FROM customers WHERE id = %s", (cid,), fetch=None)
|
||||
self._respond(200, {'status': 'ok'})
|
||||
|
||||
def _remove_extension(self, cid, ext_id):
|
||||
query("DELETE FROM customer_extensions WHERE customer_id = %s AND extension_id = %s", (cid, ext_id), fetch=None)
|
||||
self._respond(200, {'status': 'ok'})
|
||||
|
||||
Reference in New Issue
Block a user