working FileIndex and user Profile pages/settings

This commit is contained in:
JakeBreath
2026-08-03 14:13:40 -05:00
parent 85e6241ad4
commit 39e31d3980
17 changed files with 999 additions and 25 deletions
+35 -1
View File
@@ -1,3 +1,37 @@
import uuid
from django.conf import settings
from django.db import models
# Create your models here.
class FileIndex(models.Model):
"""Tracks every user file so media stays organized and served only
through the gated FileRequest endpoint (never direct /media/ access)."""
uuid = models.UUIDField(default=uuid.uuid4, editable=False, unique=True)
owner = models.ForeignKey(
settings.AUTH_USER_MODEL,
on_delete=models.SET_NULL,
null=True,
blank=True,
related_name='files',
)
kind = models.CharField(max_length=64, default='file', db_index=True)
stored_path = models.CharField(max_length=1024)
original_filename = models.CharField(max_length=255, blank=True, default='')
content_type = models.CharField(max_length=128, blank=True, default='')
size = models.IntegerField(default=0)
md5 = models.CharField(max_length=32, db_index=True)
created_at = models.DateTimeField(auto_now_add=True)
class Meta:
indexes = [
models.Index(fields=['owner', 'kind']),
]
def __str__(self):
return f'{self.kind} {self.uuid} ({self.owner})'
@property
def file_path(self):
return self.stored_path