Initial task for building

This commit is contained in:
shamoon
2025-11-04 20:55:12 -08:00
parent 9146e7fa11
commit 486982bfd4
7 changed files with 310 additions and 11 deletions

View File

@@ -823,6 +823,18 @@ class ShareBundle(SoftDeleteModel):
blank=True,
)
file_path = models.CharField(
_("file path"),
max_length=512,
blank=True,
)
built_at = models.DateTimeField(
_("built at"),
null=True,
blank=True,
)
documents = models.ManyToManyField(
"documents.Document",
related_name="share_bundles",
@@ -832,6 +844,31 @@ class ShareBundle(SoftDeleteModel):
def __str__(self):
return _("Share bundle %(slug)s") % {"slug": self.slug}
@property
def absolute_file_path(self) -> Path | None:
if not self.file_path:
return None
file_path = Path(self.file_path)
if not file_path.is_absolute():
file_path = (settings.MEDIA_ROOT / file_path).resolve()
return file_path
def remove_file(self):
path = self.absolute_file_path
if path and path.exists():
try:
path.unlink()
except OSError:
pass
def delete(self, using=None, *, keep_parents=False):
self.remove_file()
return super().delete(using=using, keep_parents=keep_parents)
def hard_delete(self, using=None, *, keep_parents=False):
self.remove_file()
return super().hard_delete(using=using, keep_parents=keep_parents)
class CustomField(models.Model):
"""