Skip to content
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

Closed

Conversation

nilaygit-10721
Copy link

@nilaygit-10721 nilaygit-10721 commented Nov 5, 2024

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

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the develop branch of the repository
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no
    visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@seancolsen seancolsen added the pr-status: review A PR awaiting review label Nov 5, 2024
@seancolsen seancolsen added this to the Backlog milestone Nov 5, 2024
@mathemancer mathemancer self-requested a review November 5, 2024 13:15
Copy link
Contributor

@mathemancer mathemancer left a 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
Copy link
Contributor

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.

Comment on lines 38 to 43
except ObjectDoesNotExist:
raise APIError(
f"User with ID {user_id} not found.",
code="user_not_found",
status_code=404
)
Copy link
Contributor

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.

@mathemancer
Copy link
Contributor

Procedural note: In the future, please use the PR template.

@nilaygit-10721
Copy link
Author

okay i will use pr template

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-status: review A PR awaiting review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement users.delete RPC function
3 participants