Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/models.py
Show First 20 Lines • Show All 141 Lines • ▼ Show 20 Lines | class Deposit(models.Model): | ||||
# deposit can have one parent | # deposit can have one parent | ||||
parent = models.ForeignKey("self", on_delete=models.PROTECT, null=True) | parent = models.ForeignKey("self", on_delete=models.PROTECT, null=True) | ||||
check_task_id = models.TextField( | check_task_id = models.TextField( | ||||
blank=True, null=True, verbose_name="Scheduler's associated checking task id" | blank=True, null=True, verbose_name="Scheduler's associated checking task id" | ||||
) | ) | ||||
load_task_id = models.TextField( | load_task_id = models.TextField( | ||||
blank=True, null=True, verbose_name="Scheduler's associated loading task id" | blank=True, null=True, verbose_name="Scheduler's associated loading task id" | ||||
) | ) | ||||
raw_metadata: Optional[str] = None | |||||
class Meta: | class Meta: | ||||
db_table = "deposit" | db_table = "deposit" | ||||
app_label = "deposit" | app_label = "deposit" | ||||
def __str__(self): | def __str__(self): | ||||
d = { | d = { | ||||
"id": self.id, | "id": self.id, | ||||
"reception_date": self.reception_date, | "reception_date": self.reception_date, | ||||
"collection": self.collection.name, | "collection": self.collection.name, | ||||
"external_id": self.external_id, | "external_id": self.external_id, | ||||
"origin_url": self.origin_url, | "origin_url": self.origin_url, | ||||
"client": self.client.username, | "client": self.client.username, | ||||
"status": self.status, | "status": self.status, | ||||
} | } | ||||
if self.status in (DEPOSIT_STATUS_REJECTED): | if self.status in (DEPOSIT_STATUS_REJECTED): | ||||
d["status_detail"] = self.status_detail | d["status_detail"] = self.status_detail | ||||
return str(d) | return str(d) | ||||
def set_raw_metadata(self, raw_metadata: str) -> None: | |||||
"""Set the metadata raw out of a 'metadata' typed deposit request. This is | |||||
specifically used during listing. | |||||
""" | |||||
self.raw_metadata = raw_metadata | |||||
def client_directory_path(instance: "DepositRequest", filename: str) -> str: | def client_directory_path(instance: "DepositRequest", filename: str) -> str: | ||||
"""Callable to determine the upload archive path. This defaults to | """Callable to determine the upload archive path. This defaults to | ||||
MEDIA_ROOT/client_<user_id>/%Y%m%d-%H%M%S.%f/<filename>. | MEDIA_ROOT/client_<user_id>/%Y%m%d-%H%M%S.%f/<filename>. | ||||
The format "%Y%m%d-%H%M%S.%f" is the reception date of the associated deposit | The format "%Y%m%d-%H%M%S.%f" is the reception date of the associated deposit | ||||
formatted using strftime. | formatted using strftime. | ||||
▲ Show 20 Lines • Show All 71 Lines • Show Last 20 Lines |