Skip to content

Commit

Permalink
Merge pull request #1664 from dandi/valid-publishable
Browse files Browse the repository at this point in the history
  • Loading branch information
danlamanna authored Jul 20, 2023
2 parents a9b48c9 + f561640 commit e652ab2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dandiapi/api/models/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def size(self):
)

@property
def valid(self) -> bool:
def publishable(self) -> bool:
if self.status != Version.Status.VALID:
return False

Expand Down
2 changes: 1 addition & 1 deletion dandiapi/api/services/publish/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _lock_dandiset_for_publishing(*, user: User, dandiset: Dandiset) -> None:

with transaction.atomic():
draft_version: Version = dandiset.versions.select_for_update().get(version='draft')
if not draft_version.valid:
if not draft_version.publishable:
match draft_version.status:
case Version.Status.PUBLISHED:
raise DandisetAlreadyPublished()
Expand Down
10 changes: 5 additions & 5 deletions dandiapi/api/tests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def test_version_valid_with_valid_asset(version, asset):
asset.status = Asset.Status.VALID
asset.save()

assert version.valid
assert version.publishable


@pytest.mark.django_db
Expand All @@ -264,7 +264,7 @@ def test_version_invalid(version, status):
version.status = status
version.save()

assert not version.valid
assert not version.publishable


@pytest.mark.django_db
Expand All @@ -285,7 +285,7 @@ def test_version_valid_with_invalid_asset(version, asset, status):
asset.status = status
asset.save()

assert not version.valid
assert not version.publishable


@pytest.mark.django_db
Expand Down Expand Up @@ -623,7 +623,7 @@ def test_version_rest_publish(
tasks.validate_asset_metadata_task(old_draft_asset.id)
tasks.validate_version_metadata_task(draft_version.id)
draft_version.refresh_from_db()
assert draft_version.valid
assert draft_version.publishable

resp = api_client.post(
f'/api/dandisets/{draft_version.dandiset.identifier}'
Expand Down Expand Up @@ -663,7 +663,7 @@ def test_version_rest_publish_zarr(
tasks.validate_asset_metadata_task(normal_asset.id)
tasks.validate_version_metadata_task(draft_version.id)
draft_version.refresh_from_db()
assert draft_version.valid
assert draft_version.publishable

resp = api_client.post(
f'/api/dandisets/{draft_version.dandiset.identifier}'
Expand Down

0 comments on commit e652ab2

Please sign in to comment.