Skip to content

Commit

Permalink
Merge pull request #1438 from dandi/allow-embargo-dandiset-deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
danlamanna authored Jan 18, 2023
2 parents e6bda73 + 9721a2e commit 6cfba52
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 0 additions & 2 deletions dandiapi/api/services/dandiset/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ def create_dandiset(
def delete_dandiset(*, user, dandiset: Dandiset) -> None:
if not user.has_perm('owner', dandiset):
raise NotAllowed('Cannot delete dandisets which you do not own.')
if dandiset.embargo_status != Dandiset.EmbargoStatus.OPEN:
raise NotAllowed('Cannot delete dandisets which are embargoed.')
if dandiset.versions.exclude(version='draft').exists():
raise NotAllowed('Cannot delete dandisets with published versions.')
if dandiset.versions.filter(status=Version.Status.PUBLISHING).exists():
Expand Down
8 changes: 7 additions & 1 deletion dandiapi/api/tests/test_dandiset.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,8 +713,14 @@ def test_dandiset_rest_create_with_invalid_identifier(api_client, admin_user):
assert response.data == f'Invalid Identifier {identifier}'


@pytest.mark.parametrize(
('embargo_status'),
[choice[0] for choice in Dandiset.EmbargoStatus.choices],
ids=[choice[1] for choice in Dandiset.EmbargoStatus.choices],
)
@pytest.mark.django_db
def test_dandiset_rest_delete(api_client, draft_version, user):
def test_dandiset_rest_delete(api_client, draft_version_factory, user, embargo_status):
draft_version = draft_version_factory(dandiset__embargo_status=embargo_status)
api_client.force_authenticate(user=user)
assign_perm('owner', user, draft_version.dandiset)

Expand Down

0 comments on commit 6cfba52

Please sign in to comment.