Fix: Allow enabled clients to be deleted and also delete the history to enable deletion
This commit is contained in:
parent
fcef417dfc
commit
d86880396d
|
@ -36,19 +36,15 @@ def update(request):
|
||||||
def delete(request):
|
def delete(request):
|
||||||
id = request.matchdict.get('id', None)
|
id = request.matchdict.get('id', None)
|
||||||
if id is None:
|
if id is None:
|
||||||
response = Response("Client is Null")
|
response = Response("Client not found")
|
||||||
response.status_int = 500
|
response.status_int = 500
|
||||||
return response
|
return response
|
||||||
|
|
||||||
client = Client.by_id(id)
|
client = Client.by_id(id)
|
||||||
if client.enabled:
|
LoginHistory.__table__.delete(LoginHistory.client_id == client.id).execute()
|
||||||
response = Response("Client is enabled and cannot be deleted")
|
DBSession.delete(client)
|
||||||
response.status_int = 500
|
transaction.commit()
|
||||||
return response
|
return {}
|
||||||
else:
|
|
||||||
DBSession.delete(client)
|
|
||||||
transaction.commit()
|
|
||||||
return {}
|
|
||||||
|
|
||||||
|
|
||||||
@view_config(request_method='GET', route_name='api_client', request_param='list', renderer='json', permission='Clients')
|
@view_config(request_method='GET', route_name='api_client', request_param='list', renderer='json', permission='Clients')
|
||||||
|
|
Loading…
Reference in New Issue