-
Notifications
You must be signed in to change notification settings - Fork 17
Upgrade djangorestframework
#2589
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
base: master
Are you sure you want to change the base?
Conversation
| r'versions', | ||
| VersionViewSet, | ||
| basename='version', | ||
| basename='dandiset-version', |
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.
Raise ImproperlyConfigured exception if
basenameis not unique [#8438]
I think this is a sensible new name, since the viewsets are nested.
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 reason for this change was that NestedAssetViewSet and AssetViewSet basenames were conflicting. I updated VersionViewSet also, just for consistency.
23a2c13 to
91551d2
Compare
| assert resp.json() == ['Zarr already exists'] | ||
| assert resp.json() == { | ||
| 'non_field_errors': ['The fields dandiset, name must make a unique set.'] | ||
| } |
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 is the new error raised by the serializer?
f7a53c7 to
f8e357e
Compare
2ba0dd2 to
046381b
Compare
2b817d8 to
bdf6846
Compare
046381b to
00a57d3
Compare
00a57d3 to
8f28855
Compare
Also rename the `VersionViewSet` for consistency.
The latest DRF now enforces uniqueness constraints in serializer validation, so all other validation should happen at the same time to avoid incorrect error codes being returned.
8f28855 to
24e2ca1
Compare
| return int(data) | ||
| except (ValueError, TypeError): | ||
| self.fail('invalid') |
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.
As it stands, this validation will miss negative numbers, as well as numbers greater than 6 digits.
| return int(data) | |
| except (ValueError, TypeError): | |
| self.fail('invalid') | |
| data = int(data) | |
| except (ValueError, TypeError): | |
| self.fail('invalid') | |
| if isinstance(data, int) and (data < 1 or data > 999_999): # noqa: PLR2004 | |
| self.fail('invalid') |
| # If this was loaded via ".get_serializer", then the request is available in context | ||
| self.user: User | AnonymousUser | None = ( | ||
| self._context['request'].user if 'request' in self._context else None | ||
| ) |
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 guess the assumption here is that if self._context['request'] is not available, this must be called by internal code, and we're okay with keeping the dandiset queryset as Dandiset.objects.all()?
| dandiset = serializers.PrimaryKeyRelatedField( | ||
| queryset=Dandiset.objects.all(), | ||
| pk_field=DandisetIdentifierField(), | ||
| ) |
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.
Does this automatically raise an exception if the specified dandiset ID is not found? And if so, what's the response code (seems like it might be 400 instead of 404)?
Fixes #1896