-
Notifications
You must be signed in to change notification settings - Fork 458
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
Release/3.0.0 #820
base: master
Are you sure you want to change the base?
Release/3.0.0 #820
Conversation
djoser/views/user/user.py
Outdated
User = get_user_model() | ||
|
||
|
||
class UserViewSet(viewsets.ModelViewSet): |
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.
should it be split further?
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.
I think it makes sense to split completely small views.
I think the whole point of splitting is that you can easily get any view, extend it or modify its behavior and inject to your project ONLY what you want.
With this viewset if you don't want to have e.g. update code in you project you can only remove the url pattern, but not the view handler.
Taking a lesson from the community feedback, I would say that viewset is not the best choice for a library.
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.
I split everything as much as possible, but I doubt me
can be split further as then we can't register it under the same endpoint, even though it uses a different http method, no?
@@ -72,8 +73,11 @@ def test_user_can_get_other_user_detail(self): | |||
|
|||
def test_user_cant_set_other_user_detail(self): | |||
login_user(self.client, self.user) | |||
response = self.client.get(reverse("user-detail", args=[self.superuser.pk])) | |||
self.assert_status_equal(response, status.HTTP_200_OK) | |||
response = self.client.patch( |
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.
test body copied from above (dupe), did not match the test name
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.
Overall looks good, however I'm in favor of further splitting!
djoser/urls/authtoken.py
Outdated
re_path(r"^token/login/?$", views.TokenCreateView.as_view(), name="login"), | ||
re_path(r"^token/logout/?$", views.TokenDestroyView.as_view(), name="logout"), | ||
re_path(r"^token/login/?$", TokenCreateView.as_view(), name="login"), | ||
re_path(r"^token/logout/?$", TokenDestroyView.as_view(), name="logout"), |
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 may want to switch to url()
instead of re_path
by the way of doing this views split.
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.
djoser/views/user/user.py
Outdated
User = get_user_model() | ||
|
||
|
||
class UserViewSet(viewsets.ModelViewSet): |
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.
I think it makes sense to split completely small views.
I think the whole point of splitting is that you can easily get any view, extend it or modify its behavior and inject to your project ONLY what you want.
With this viewset if you don't want to have e.g. update code in you project you can only remove the url pattern, but not the view handler.
Taking a lesson from the community feedback, I would say that viewset is not the best choice for a library.
# Conflicts: # djoser/views.py
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #820 +/- ##
==========================================
- Coverage 98.67% 98.57% -0.10%
==========================================
Files 27 39 +12
Lines 903 981 +78
==========================================
+ Hits 891 967 +76
- Misses 12 14 +2 ☔ View full report in Codecov by Sentry. |
todos:
post
methods body vs upstream ModelViewSet actions