diff options
author | Matthew Lemon <y@yulqen.org> | 2024-05-13 17:26:25 +0100 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-05-13 17:26:25 +0100 |
commit | efbbd480ddc62e695123d31c31d233b0df5155bd (patch) | |
tree | bc2fb465edd5050d83c97f280b1aac8e023fe3e5 /pyblackbird_cc/users/models.py |
After first pre-commit processing
Diffstat (limited to 'pyblackbird_cc/users/models.py')
-rw-r--r-- | pyblackbird_cc/users/models.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/pyblackbird_cc/users/models.py b/pyblackbird_cc/users/models.py new file mode 100644 index 0000000..f536bc7 --- /dev/null +++ b/pyblackbird_cc/users/models.py @@ -0,0 +1,38 @@ +from typing import ClassVar + +from django.contrib.auth.models import AbstractUser +from django.db.models import CharField +from django.db.models import EmailField +from django.urls import reverse +from django.utils.translation import gettext_lazy as _ + +from .managers import UserManager + + +class User(AbstractUser): + """ + Default custom user model for pyblackbird-cc. + If adding fields that need to be filled at user signup, + check forms.SignupForm and forms.SocialSignupForms accordingly. + """ + + # First and last name do not cover name patterns around the globe + name = CharField(_("Name of User"), blank=True, max_length=255) + first_name = None # type: ignore[assignment] + last_name = None # type: ignore[assignment] + email = EmailField(_("email address"), unique=True) + username = None # type: ignore[assignment] + + USERNAME_FIELD = "email" + REQUIRED_FIELDS = [] + + objects: ClassVar[UserManager] = UserManager() + + def get_absolute_url(self) -> str: + """Get URL for user's detail view. + + Returns: + str: URL for user detail. + + """ + return reverse("users:detail", kwargs={"pk": self.id}) |