Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/api/common.py
Show First 20 Lines • Show All 811 Lines • ▼ Show 20 Lines | ) -> Receipt: | ||||
): | ): | ||||
raise DepositError( | raise DepositError( | ||||
BAD_REQUEST, | BAD_REQUEST, | ||||
"<swh:reference> is for metadata-only deposits and " | "<swh:reference> is for metadata-only deposits and " | ||||
"<swh:create_origin> / <swh:add_to_origin> / Slug are for " | "<swh:create_origin> / <swh:add_to_origin> / Slug are for " | ||||
"code deposits, only one may be used on a given deposit.", | "code deposits, only one may be used on a given deposit.", | ||||
) | ) | ||||
self._deposit_put( | |||||
deposit=deposit, in_progress=headers.in_progress, | |||||
) | |||||
if swhid is not None: | if swhid is not None: | ||||
deposit.save() # We need a deposit id | |||||
swhid, swhid_ref, depo, depo_request = self._store_metadata_deposit( | swhid, swhid_ref, depo, depo_request = self._store_metadata_deposit( | ||||
vlorentz: I don't think it needs to be called at all. | |||||
Done Inline Actionsit fails without it (tested on staging, i got a stacktrace) ardumont: it fails without it (tested on staging, i got a stacktrace) | |||||
Done Inline Actionserror without [1] [1] P907 ardumont: error without [1]
(my first approach was naively to push the _deposit_put call down, after the… | |||||
Not Done Inline ActionsAh yes, you just need to call deposit.save() so Django gets a PK it can use as the FK in the deposit request table. vlorentz: Ah yes, you just need to call `deposit.save()` so Django gets a PK it can use as the FK in the… | |||||
deposit, swhid, metadata, raw_metadata | deposit, swhid, metadata, raw_metadata | ||||
) | ) | ||||
deposit.status = DEPOSIT_STATUS_LOAD_SUCCESS | deposit.status = DEPOSIT_STATUS_LOAD_SUCCESS | ||||
if isinstance(swhid_ref, SWHID): | if isinstance(swhid_ref, SWHID): | ||||
deposit.swhid = str(swhid) | deposit.swhid = str(swhid) | ||||
deposit.swhid_context = str(swhid_ref) | deposit.swhid_context = str(swhid_ref) | ||||
deposit.complete_date = depo_request.date | deposit.complete_date = depo_request.date | ||||
deposit.reception_date = depo_request.date | deposit.reception_date = depo_request.date | ||||
deposit.save() | deposit.save() | ||||
return Receipt( | return Receipt( | ||||
deposit_id=deposit.id, | deposit_id=deposit.id, | ||||
deposit_date=depo_request.date, | deposit_date=depo_request.date, | ||||
status=deposit.status, | status=deposit.status, | ||||
archive=None, | archive=None, | ||||
) | ) | ||||
self._deposit_put( | |||||
deposit=deposit, in_progress=headers.in_progress, | |||||
) | |||||
self._deposit_request_put( | self._deposit_request_put( | ||||
deposit, | deposit, | ||||
{METADATA_KEY: metadata, RAW_METADATA_KEY: raw_metadata}, | {METADATA_KEY: metadata, RAW_METADATA_KEY: raw_metadata}, | ||||
replace_metadata, | replace_metadata, | ||||
replace_archives, | replace_archives, | ||||
) | ) | ||||
return Receipt( | return Receipt( | ||||
▲ Show 20 Lines • Show All 343 Lines • Show Last 20 Lines |
I don't think it needs to be called at all.