From d86880396d44c5fb1cc930ac8dfaee86efe3420a Mon Sep 17 00:00:00 2001 From: Amritanshu Date: Fri, 12 Sep 2014 12:59:09 +0530 Subject: [PATCH] Fix: Allow enabled clients to be deleted and also delete the history to enable deletion --- brewman/views/auth/client.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/brewman/views/auth/client.py b/brewman/views/auth/client.py index 3d8c39e0..156a7079 100644 --- a/brewman/views/auth/client.py +++ b/brewman/views/auth/client.py @@ -36,19 +36,15 @@ def update(request): def delete(request): id = request.matchdict.get('id', None) if id is None: - response = Response("Client is Null") + response = Response("Client not found") response.status_int = 500 return response client = Client.by_id(id) - if client.enabled: - response = Response("Client is enabled and cannot be deleted") - response.status_int = 500 - return response - else: - DBSession.delete(client) - transaction.commit() - return {} + LoginHistory.__table__.delete(LoginHistory.client_id == client.id).execute() + DBSession.delete(client) + transaction.commit() + return {} @view_config(request_method='GET', route_name='api_client', request_param='list', renderer='json', permission='Clients')