from django.db import models
from django.contrib.auth.models import User

def user_avatar_path(instance, filename):
    return f'static/uploads/avatars/{instance.user.id}/{filename}'

class Profile(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    avatar = models.ImageField(upload_to=user_avatar_path, default='default.jpg')
    first_name = models.CharField(max_length=64, blank=True)
    last_name = models.CharField(max_length=64, blank=True)
    birth_date = models.DateField(null=True, blank=True)
    biography = models.TextField(blank=True)
    is_premium = models.BooleanField(default=False)

    def __str__(self):
        return self.user.username