Skip to content

Commit

Permalink
Rearrange embargo exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
jjnesbitt committed Jun 17, 2024
1 parent b789645 commit 6ae94fc
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 21 deletions.
6 changes: 2 additions & 4 deletions dandiapi/api/services/dandiset/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@

from dandiapi.api.models.dandiset import Dandiset
from dandiapi.api.models.version import Version
from dandiapi.api.services.dandiset.exceptions import (
DandisetAlreadyExistsError,
DandisetUnEmbargoInProgressError,
)
from dandiapi.api.services.dandiset.exceptions import DandisetAlreadyExistsError
from dandiapi.api.services.embargo.exceptions import DandisetUnEmbargoInProgressError
from dandiapi.api.services.exceptions import AdminOnlyOperationError, NotAllowedError
from dandiapi.api.services.version.metadata import _normalize_version_metadata

Expand Down
12 changes: 0 additions & 12 deletions dandiapi/api/services/dandiset/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,3 @@

class DandisetAlreadyExistsError(DandiError):
http_status_code = status.HTTP_400_BAD_REQUEST


class UnauthorizedEmbargoAccessError(DandiError):
http_status_code = status.HTTP_401_UNAUTHORIZED
message = (
'Authentication credentials must be provided when attempting to access embargoed dandisets'
)


class DandisetUnEmbargoInProgressError(DandiError):
http_status_code = status.HTTP_400_BAD_REQUEST
message = 'Dandiset modification not allowed during un-embargo'
12 changes: 12 additions & 0 deletions dandiapi/api/services/embargo/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,15 @@ class DandisetNotEmbargoedError(DandiError):
class DandisetActiveUploadsError(DandiError):
http_status_code = status.HTTP_400_BAD_REQUEST
message = 'Dandiset un-embargo not allowed with active uploads'


class DandisetUnEmbargoInProgressError(DandiError):
http_status_code = status.HTTP_400_BAD_REQUEST
message = 'Dandiset modification not allowed during un-embargo'


class UnauthorizedEmbargoAccessError(DandiError):
http_status_code = status.HTTP_401_UNAUTHORIZED
message = (
'Authentication credentials must be provided when attempting to access embargoed dandisets'
)
2 changes: 1 addition & 1 deletion dandiapi/api/views/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
remove_asset_from_version,
)
from dandiapi.api.services.asset.exceptions import DraftDandisetNotModifiableError
from dandiapi.api.services.dandiset.exceptions import DandisetUnEmbargoInProgressError
from dandiapi.api.services.embargo.exceptions import DandisetUnEmbargoInProgressError
from dandiapi.zarr.models import ZarrArchive

try:
Expand Down
4 changes: 2 additions & 2 deletions dandiapi/api/views/dandiset.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
from dandiapi.api.mail import send_ownership_change_emails
from dandiapi.api.models import Dandiset, Version
from dandiapi.api.services.dandiset import create_dandiset, delete_dandiset
from dandiapi.api.services.dandiset.exceptions import (
from dandiapi.api.services.embargo import unembargo_dandiset
from dandiapi.api.services.embargo.exceptions import (
DandisetUnEmbargoInProgressError,
UnauthorizedEmbargoAccessError,
)
from dandiapi.api.services.embargo import unembargo_dandiset
from dandiapi.api.views.common import DANDISET_PK_PARAM
from dandiapi.api.views.pagination import DandiPagination
from dandiapi.api.views.serializers import (
Expand Down
2 changes: 1 addition & 1 deletion dandiapi/api/views/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from dandiapi.api.models import AssetBlob, Dandiset, Upload
from dandiapi.api.permissions import IsApproved
from dandiapi.api.services.dandiset.exceptions import DandisetUnEmbargoInProgressError
from dandiapi.api.services.embargo.exceptions import DandisetUnEmbargoInProgressError
from dandiapi.api.tasks import calculate_sha256
from dandiapi.api.views.serializers import AssetBlobSerializer

Expand Down
2 changes: 1 addition & 1 deletion dandiapi/api/views/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from rest_framework_extensions.mixins import DetailSerializerMixin, NestedViewSetMixin

from dandiapi.api.models import Dandiset, Version
from dandiapi.api.services.dandiset.exceptions import DandisetUnEmbargoInProgressError
from dandiapi.api.services.embargo.exceptions import DandisetUnEmbargoInProgressError
from dandiapi.api.services.publish import publish_dandiset
from dandiapi.api.tasks import delete_doi_task
from dandiapi.api.views.common import DANDISET_PK_PARAM, VERSION_PARAM
Expand Down

0 comments on commit 6ae94fc

Please sign in to comment.