2016-05-08 20:18:13 +00:00
|
|
|
from sqlalchemy import Column, Integer, Unicode, DateTime
|
2016-04-03 20:03:58 +00:00
|
|
|
from szurubooru.db.base import Base
|
2016-03-19 20:37:04 +00:00
|
|
|
|
|
|
|
class User(Base):
|
|
|
|
__tablename__ = 'user'
|
|
|
|
|
2016-04-09 19:41:10 +00:00
|
|
|
AVATAR_GRAVATAR = 'gravatar'
|
|
|
|
AVATAR_MANUAL = 'manual'
|
2016-03-28 12:14:50 +00:00
|
|
|
|
2016-05-08 14:59:25 +00:00
|
|
|
RANK_ANONYMOUS = 'anonymous'
|
|
|
|
RANK_RESTRICTED = 'restricted'
|
|
|
|
RANK_REGULAR = 'regular'
|
|
|
|
RANK_POWER = 'power'
|
|
|
|
RANK_MODERATOR = 'moderator'
|
|
|
|
RANK_ADMINISTRATOR = 'administrator'
|
|
|
|
RANK_NOBODY = 'nobody'
|
|
|
|
ALL_RANKS = [
|
|
|
|
RANK_ANONYMOUS,
|
|
|
|
RANK_RESTRICTED,
|
|
|
|
RANK_REGULAR,
|
|
|
|
RANK_POWER,
|
|
|
|
RANK_MODERATOR,
|
|
|
|
RANK_ADMINISTRATOR,
|
|
|
|
RANK_NOBODY, # nobody can have higher privileges than administrator
|
|
|
|
]
|
|
|
|
|
2016-04-15 18:40:12 +00:00
|
|
|
user_id = Column('id', Integer, primary_key=True)
|
2016-05-08 20:18:13 +00:00
|
|
|
name = Column('name', Unicode(50), nullable=False, unique=True)
|
|
|
|
password_hash = Column('password_hash', Unicode(64), nullable=False)
|
|
|
|
password_salt = Column('password_salt', Unicode(32))
|
|
|
|
email = Column('email', Unicode(64), nullable=True)
|
|
|
|
rank = Column('rank', Unicode(32), nullable=False)
|
2016-04-15 18:40:12 +00:00
|
|
|
creation_time = Column('creation_time', DateTime, nullable=False)
|
|
|
|
last_login_time = Column('last_login_time', DateTime)
|
|
|
|
avatar_style = Column(
|
2016-05-08 20:18:13 +00:00
|
|
|
'avatar_style', Unicode(32), nullable=False, default=AVATAR_GRAVATAR)
|