Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/api/common.py
Show First 20 Lines • Show All 220 Lines • ▼ Show 20 Lines | class APIBase(APIConfig, AuthenticatedAPIView, metaclass=ABCMeta): | ||||
def _complete_deposit(self, deposit: Deposit) -> None: | def _complete_deposit(self, deposit: Deposit) -> None: | ||||
"""Marks the deposit as 'deposited', then schedule a check task if configured | """Marks the deposit as 'deposited', then schedule a check task if configured | ||||
to do so.""" | to do so.""" | ||||
deposit.complete_date = timezone.now() | deposit.complete_date = timezone.now() | ||||
deposit.status = DEPOSIT_STATUS_DEPOSITED | deposit.status = DEPOSIT_STATUS_DEPOSITED | ||||
deposit.save() | deposit.save() | ||||
if deposit.external_id and not deposit.origin_url: | |||||
deposit.origin_url = guess_deposit_origin_url(deposit) | |||||
if self.config["checks"]: | if self.config["checks"]: | ||||
scheduler = self.scheduler | scheduler = self.scheduler | ||||
if deposit.status == DEPOSIT_STATUS_DEPOSITED and not deposit.check_task_id: | if deposit.status == DEPOSIT_STATUS_DEPOSITED and not deposit.check_task_id: | ||||
task = create_oneshot_task_dict( | task = create_oneshot_task_dict( | ||||
"check-deposit", | "check-deposit", | ||||
collection=deposit.collection.name, | collection=deposit.collection.name, | ||||
deposit_id=deposit.id, | deposit_id=deposit.id, | ||||
retries_left=3, | retries_left=3, | ||||
) | ) | ||||
check_task_id = scheduler.create_tasks([task])[0]["id"] | check_task_id = scheduler.create_tasks([task])[0]["id"] | ||||
deposit.check_task_id = check_task_id | deposit.check_task_id = check_task_id | ||||
deposit.save() | deposit.save() | ||||
def _deposit_request_put( | def _deposit_request_put( | ||||
self, | self, | ||||
deposit: Deposit, | deposit: Deposit, | ||||
deposit_request_data: Dict[str, Any], | deposit_request_data: Dict[str, Any], | ||||
replace_metadata: bool = False, | replace_metadata: bool = False, | ||||
replace_archives: bool = False, | replace_archives: bool = False, | ||||
) -> DepositRequest: | ) -> DepositRequest: | ||||
▲ Show 20 Lines • Show All 896 Lines • Show Last 20 Lines |