diff options
Diffstat (limited to 'gn_auth')
-rw-r--r-- | gn_auth/auth/authorisation/resources/views.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/gn_auth/auth/authorisation/resources/views.py b/gn_auth/auth/authorisation/resources/views.py index cee3d6c..920ea76 100644 --- a/gn_auth/auth/authorisation/resources/views.py +++ b/gn_auth/auth/authorisation/resources/views.py @@ -50,7 +50,7 @@ from .models import ( resource_categories, assign_resource_user, link_data_to_resource, unassign_resource_user, resource_category_by_id, user_roles_on_resources, unlink_data_from_resource, create_resource as _create_resource, - get_resource_id) + get_resource_id, delete_resource as _delete_resource) resources = Blueprint("resources", __name__) resources.register_blueprint(popbp, url_prefix="/") @@ -691,7 +691,7 @@ def delete_resource() -> Response: conn, the_token.user.user_id, resource_id, - "(OR group:resource:delete-resource system:resource:delete-all)"): + "(OR group:resource:delete-resource system:resource:delete)"): raise AuthorisationError("You do not have the appropriate " "privileges to delete this resource.") @@ -705,14 +705,19 @@ def delete_resource() -> Response: "error": "NonEmptyResouce", "error-description": "Cannot delete a resource with linked data" }), 400 + + _delete_resource(conn, resource_id) + return jsonify({ + "description": f"Successfully deleted resource with ID '{resource_id}'." + }) except ValueError as _verr: - logger.debug("Error!", exc_info=True) + app.logger.debug("Error!", exc_info=True) return jsonify({ "error": "ValueError", "error-description": "An invalid identifier was provided" }), 400 except TypeError as _terr: - logger.debug("Error!", exc_info=True) + app.logger.debug("Error!", exc_info=True) return jsonify({ "error": "TypeError", "error-description": "An invalid identifier was provided" |