"""User model.

When ``use_auth == "yes"`` the ``hashed_password`` field is present;
otherwise the model holds only the public profile fields.
"""

from __future__ import annotations

from tortoise import fields
from tortoise.models import Model


class User(Model):
    id = fields.IntField(pk=True)
    username = fields.CharField(max_length=64, unique=True)
    email = fields.CharField(max_length=128, unique=True)
{% if cookiecutter.use_auth == "yes" %}
    hashed_password = fields.CharField(max_length=255)
{% endif %}

    class Meta:
        table = "users"

    def __str__(self) -> str:
        return self.username