-
-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement users.delete RPC function to replace DELETE /api/ui/v0/users/{userId}/ endpoint #4014
Implement users.delete RPC function to replace DELETE /api/ui/v0/users/{userId}/ endpoint #4014
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good start!
Please also:
- satisfy the linter
- add a couple tests (see the other RPC function tests)
- wire this up to the actual API by adding the appropriate line in the
common_settings.py
file - add a docstring similar to the other RPC functions
- wire this into the project documentation in the
docs/docs/api/rpc.md
file.
Thanks for your effort so far!
from django.contrib.auth import get_user_model | ||
from django.core.exceptions import ObjectDoesNotExist | ||
|
||
from mathesar.api.exceptions import APIError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The APIError
class is only for use in the (now deprecated) REST API. It's not a good idea here. You should raise a custom error class based on a standard Python Exception
instead.
mathesar/api/rpc/users/base.py
Outdated
except ObjectDoesNotExist: | ||
raise APIError( | ||
f"User with ID {user_id} not found.", | ||
code="user_not_found", | ||
status_code=404 | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need a custom error here. Just let it fail.
Procedural note: In the future, please use the PR template. |
okay i will use pr template |
Fixes #4000
This pull request implements the users.delete RPC function to replace the existing DELETE /api/ui/v0/users/{userId}/ endpoint. The function follows the specified signature and includes necessary decorators for authorization and error handling. This change enhances the API's structure by moving user model manipulations to the RPC layer, improving maintainability and scalability.
Checklist
Update index.md
).develop
branch of the repositoryvisible errors.
Developer Certificate of Origin
Developer Certificate of Origin