Skip to content

Commit

Permalink
Add user.pubid to the model
Browse files Browse the repository at this point in the history
  • Loading branch information
mtomilov committed Jan 15, 2025
1 parent 1ba5172 commit 84bcd8d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions h/models/user.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import datetime
import re
from functools import partial
from typing import TYPE_CHECKING

import sqlalchemy as sa
Expand All @@ -9,6 +10,7 @@
from h.db import Base
from h.exceptions import InvalidUserId
from h.models import helpers
from h.pubid import generate
from h.util.user import format_userid, split_user

if TYPE_CHECKING:
Expand All @@ -20,6 +22,7 @@
USERNAME_PATTERN = "(?i)^[A-Z0-9._]+$"
EMAIL_MAX_LENGTH = 100
DISPLAY_NAME_MAX_LENGTH = 30
USER_PUBID_LENGTH = 12


def _normalise_username(username):
Expand Down Expand Up @@ -158,6 +161,14 @@ def __table_args__(cls): # pylint:disable=no-self-argument

id = sa.Column(sa.Integer, autoincrement=True, primary_key=True)

#: A publicly visible unique identifier for the user
pubid = sa.Column(
sa.Text(),
default=partial(generate, USER_PUBID_LENGTH),
unique=True,
nullable=True,
)

#: Username as chosen by the user on registration
_username = sa.Column("username", sa.UnicodeText(), nullable=False)

Expand Down

0 comments on commit 84bcd8d

Please sign in to comment.