diff options
author | Frederick Muriuki Muriithi | 2025-07-29 13:22:48 -0500 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2025-07-29 13:22:48 -0500 |
commit | 6981414dd8e713b7b910912979dbaa7ee98cfa6c (patch) | |
tree | 7dc3edbf25f8de4cb1777b6846ef71cef0aea23b | |
parent | 4346b93c3f0b86860383e91a3df0e440e0f3066b (diff) | |
download | gn-auth-6981414dd8e713b7b910912979dbaa7ee98cfa6c.tar.gz |
Actually delete a resource.
-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" |