Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/api/collection.py
Show All 15 Lines | from ..parsers import ( | ||||
SWHMultiPartParser, | SWHMultiPartParser, | ||||
) | ) | ||||
from .common import ( | from .common import ( | ||||
ACCEPT_ARCHIVE_CONTENT_TYPES, | ACCEPT_ARCHIVE_CONTENT_TYPES, | ||||
APIPost, | APIPost, | ||||
ParsedRequestHeaders, | ParsedRequestHeaders, | ||||
Receipt, | Receipt, | ||||
get_collection_by_name, | get_collection_by_name, | ||||
guess_deposit_origin_url, | |||||
) | ) | ||||
class CollectionAPI(APIPost): | class CollectionAPI(APIPost): | ||||
"""Deposit request class defining api endpoints for sword deposit. | """Deposit request class defining api endpoints for sword deposit. | ||||
What's known as 'Col-IRI' in the sword specification. | What's known as 'Col-IRI' in the sword specification. | ||||
▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | ) -> Deposit: | ||||
) | ) | ||||
.order_by("-id")[0:1] | .order_by("-id")[0:1] | ||||
.get() | .get() | ||||
) | ) | ||||
except Deposit.DoesNotExist: | except Deposit.DoesNotExist: | ||||
# then no parent for that deposit, deposit_parent already None | # then no parent for that deposit, deposit_parent already None | ||||
pass | pass | ||||
deposit = Deposit( | return Deposit( | ||||
collection=collection, | collection=collection, | ||||
external_id=external_id or "", | external_id=external_id or "", | ||||
client=client, | client=client, | ||||
parent=deposit_parent, | parent=deposit_parent, | ||||
) | ) | ||||
deposit.origin_url = guess_deposit_origin_url(deposit) | |||||
return deposit |