Bases: Model
Model for additional metadata for dataset-file relation.
Source code in src/apps/core/models/file_metadata.py
| class FileSetFileMetadata(models.Model):
"""Model for additional metadata for dataset-file relation."""
copier = ModelCopier(copied_relations=[], parent_relations=["file_set"])
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
file_set = models.ForeignKey(
"core.FileSet", related_name="file_metadata", editable=False, on_delete=models.CASCADE
)
file = models.ForeignKey(File, related_name="dataset_metadata", on_delete=models.CASCADE)
title = models.TextField(null=True, blank=True)
description = models.TextField(null=True, blank=True)
file_type = models.ForeignKey(FileType, null=True, on_delete=models.SET_NULL)
use_category = models.ForeignKey(UseCategory, null=True, on_delete=models.SET_NULL)
def to_legacy(self):
return omit_empty(
{
"identifier": str(self.file.storage_identifier),
"title": self.title,
"description": self.description,
"file_type": refdata_to_legacy(self.file_type),
"use_category": refdata_to_legacy(self.use_category),
}
)
class Meta:
ordering = ["id"]
unique_together = [("file_set", "file")]
|