working FileIndex and user Profile pages/settings

This commit is contained in:
2026-08-03 14:13:40 -05:00
parent 85e6241ad4
commit 39e31d3980
17 changed files with 999 additions and 25 deletions
+18 -3
View File
@@ -1,5 +1,8 @@
from django.conf import settings
from django.db import models
from django.urls import reverse
BIO_MAX_LENGTH = 1000
class UserProfile(models.Model):
@@ -8,14 +11,26 @@ class UserProfile(models.Model):
on_delete=models.CASCADE,
related_name='userprofile',
)
bio = models.TextField(blank=True, default='')
avatar = models.ImageField(
upload_to='profiles/%d/',
bio = models.CharField(
max_length=BIO_MAX_LENGTH,
blank=True,
default='',
)
avatar = models.OneToOneField(
'library.FileIndex',
on_delete=models.SET_NULL,
null=True,
blank=True,
related_name='profile',
)
joined = models.DateTimeField(auto_now_add=True)
@property
def avatar_url(self):
if self.avatar_id is None:
return None
return reverse('library:file_request', args=[self.avatar.uuid])
def __str__(self):
return f'{self.user.username} profile'