Fix: Allow enabled clients to be deleted and also delete the history to enable deletion

This commit is contained in:
Amritanshu 2014-09-12 12:59:09 +05:30
parent fcef417dfc
commit d86880396d

View File

@ -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')