From f561640e36851af5554fc55bec2ffa306d7cd0bd Mon Sep 17 00:00:00 2001 From: Dan LaManna Date: Thu, 20 Jul 2023 11:55:42 -0400 Subject: [PATCH] Rename Version.valid to Version.publishable --- dandiapi/api/models/version.py | 2 +- dandiapi/api/services/publish/__init__.py | 2 +- dandiapi/api/tests/test_version.py | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dandiapi/api/models/version.py b/dandiapi/api/models/version.py index a0d7feed7..2729ccc74 100644 --- a/dandiapi/api/models/version.py +++ b/dandiapi/api/models/version.py @@ -70,7 +70,7 @@ def size(self): ) @property - def valid(self) -> bool: + def publishable(self) -> bool: if self.status != Version.Status.VALID: return False diff --git a/dandiapi/api/services/publish/__init__.py b/dandiapi/api/services/publish/__init__.py index c25b63880..561008df8 100644 --- a/dandiapi/api/services/publish/__init__.py +++ b/dandiapi/api/services/publish/__init__.py @@ -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() diff --git a/dandiapi/api/tests/test_version.py b/dandiapi/api/tests/test_version.py index c7e8a5fb5..619b2aca7 100644 --- a/dandiapi/api/tests/test_version.py +++ b/dandiapi/api/tests/test_version.py @@ -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 @@ -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 @@ -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 @@ -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}' @@ -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}'