def update_perm(perm_id): if not request.json: raise ApiError('nothing to change', 400) for s in request.json.get('scopes', []): if s not in list(Scope): raise ApiError("'{}' is not a valid Scope".format(s), 400) perm = Permission.find_by_id(perm_id) if not perm: raise ApiError('not found', 404) admin_audit_trail.send(current_app._get_current_object(), event='permission-updated', message='', user=g.login, customers=g.customers, scopes=g.scopes, resource_id=perm.id, type='permission', request=request) if perm.update(**request.json): return jsonify(status='ok') else: raise ApiError('failed to update permission', 500)
def get_perm(perm_id): perm = Permission.find_by_id(perm_id) if perm: return jsonify(status='ok', total=1, permission=perm.serialize) else: raise ApiError('not found', 404)
def delete_perm(perm_id): perm = Permission.find_by_id(perm_id) if not perm: raise ApiError("not found", 404) if perm.delete(): return jsonify(status="ok") else: raise ApiError("failed to delete permission", 500)
def delete_perm(perm_id): perm = Permission.find_by_id(perm_id) if not perm: raise ApiError('not found', 404) if perm.delete(): return jsonify(status='ok') else: raise ApiError('failed to delete permission', 500)
def delete_perm(perm_id): perm = Permission.find_by_id(perm_id) if not perm: raise ApiError('not found', 404) admin_audit_trail.send(current_app._get_current_object(), event='permission-deleted', message='', user=g.user, customers=g.customers, scopes=g.scopes, resource_id=perm.id, type='permission', request=request) if perm.delete(): return jsonify(status='ok') else: raise ApiError('failed to delete permission', 500)
def delete_perm(perm_id): perm = Permission.find_by_id(perm_id) if not perm: raise ApiError('not found', 404) admin_audit_trail.send(current_app._get_current_object(), event='permission-deleted', message='', user=g.login, customers=g.customers, scopes=g.scopes, resource_id=perm.id, type='permission', request=request) if perm.delete(): return jsonify(status='ok') else: raise ApiError('failed to delete permission', 500)