-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Allow users to remove themselves from a project #8384
Conversation
This is only possible if they aren't the only one left
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.
Looks good other than the UX and template logic.
@@ -553,12 +557,15 @@ def post(self, request, *args, **kwargs): | |||
self.get_queryset(), | |||
username=username, | |||
) | |||
if user == request.user: | |||
if self._is_last_user(): | |||
raise Http404 |
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.
This seems like a bad UX. We probably want some kind of messaging, not a blank 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.
yeah, but this is outisede a form, not sure if we can display an error to the view level instead of the form level. Also this case also only happens if the user triggers the request manually or if another user has removed itself in another request, the UI doesn't show you the option if you are the only one.
Let me know if we should still display an error, maybe in the 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.
Wouldn't this be a 400 saying that you can't remove yourself if you are the last/only user of the project?
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.
Could this be validated in the form?
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.
We don't have a form here, this is just a normal view (we don't display the option to remove yourself if you are the only one left). I have changed the status code to 400.
This is only possible if they aren't the only one left.
Closes #7527