Skip to content

Commit 00a57d3

Browse files
committed
Upgrade djangorestframework
1 parent 8d92bfd commit 00a57d3

File tree

5 files changed

+18
-26
lines changed

5 files changed

+18
-26
lines changed

dandiapi/urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@
4545
.register(
4646
r'versions',
4747
VersionViewSet,
48-
basename='version',
48+
basename='dandiset-version',
4949
parents_query_lookups=[f'dandiset__{DandisetViewSet.lookup_field}'],
5050
)
5151
.register(
5252
r'assets',
5353
NestedAssetViewSet,
54-
basename='asset',
54+
basename='dandiset-version-asset',
5555
parents_query_lookups=[
5656
f'versions__dandiset__{DandisetViewSet.lookup_field}',
5757
f'versions__{VersionViewSet.lookup_field}',

dandiapi/zarr/tests/test_zarr.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ def test_zarr_rest_dandiset_malformed(authenticated_api_client, user):
5757

5858

5959
@pytest.mark.django_db
60-
def test_zarr_rest_create_not_an_owner(authenticated_api_client, zarr_archive):
60+
def test_zarr_rest_create_not_an_owner(authenticated_api_client, dandiset):
6161
resp = authenticated_api_client.post(
6262
'/api/zarr/',
6363
{
64-
'name': zarr_archive.name,
65-
'dandiset': zarr_archive.dandiset.identifier,
64+
'name': 'New Zarr',
65+
'dandiset': dandiset.identifier,
6666
},
6767
)
6868
assert resp.status_code == 403
@@ -79,7 +79,9 @@ def test_zarr_rest_create_duplicate(authenticated_api_client, user, zarr_archive
7979
},
8080
)
8181
assert resp.status_code == 400
82-
assert resp.json() == ['Zarr already exists']
82+
assert resp.json() == {
83+
'non_field_errors': ['The fields dandiset, name must make a unique set.']
84+
}
8385

8486

8587
@pytest.mark.django_db

dandiapi/zarr/views/__init__.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
import logging
44
from typing import TYPE_CHECKING
55

6-
from django.db import IntegrityError, transaction
6+
from django.db import transaction
77
from django.http import HttpResponseRedirect
88
from drf_yasg.utils import no_body, swagger_auto_schema
99
from rest_framework import serializers, status
1010
from rest_framework.decorators import action
11-
from rest_framework.exceptions import PermissionDenied, ValidationError
11+
from rest_framework.exceptions import PermissionDenied
1212
from rest_framework.generics import get_object_or_404
1313
from rest_framework.response import Response
1414
from rest_framework.utils.urls import replace_query_param
@@ -151,16 +151,9 @@ def create(self, request):
151151
http_status_code=status.HTTP_400_BAD_REQUEST,
152152
)
153153

154-
zarr_archive: ZarrArchive = ZarrArchive(name=name, dandiset=dandiset)
155-
with transaction.atomic():
156-
# Use nested transaction block to prevent zarr creation race condition
157-
try:
158-
with transaction.atomic():
159-
zarr_archive.save()
160-
except IntegrityError as e:
161-
raise ValidationError('Zarr already exists') from e
162-
163-
audit.create_zarr(dandiset=dandiset, user=request.user, zarr_archive=zarr_archive)
154+
zarr_archive: ZarrArchive = ZarrArchive.objects.create(name=name, dandiset=dandiset)
155+
156+
audit.create_zarr(dandiset=dandiset, user=request.user, zarr_archive=zarr_archive)
164157

165158
serializer = ZarrSerializer(instance=zarr_archive)
166159
return Response(serializer.data, status=status.HTTP_200_OK)

pyproject.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ dependencies = [
2727
"django-resonant-settings[allauth,celery]",
2828
"django-resonant-utils",
2929
"django-stubs-ext",
30-
# TODO: pin djangorestframework until we figure out what the cause of
31-
# https://github.com/dandi/dandi-archive/issues/1896 is.
32-
"djangorestframework<3.15.0",
30+
"djangorestframework",
3331
"drf-extensions",
3432
"drf-yasg",
3533
"fsspec[http]",

uv.lock

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)