A multipurpose python flask API server and administration SPA
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.6 KiB

  1. from corvus import db
  2. class User(db.Model):
  3. __tablename__ = 'user'
  4. ROLE_USER = 'USER'
  5. ROLE_ADMIN = 'ADMIN'
  6. id = db.Column(db.Integer, primary_key=True)
  7. name = db.Column(db.Unicode(60), unique=True, nullable=False)
  8. role = db.Column(
  9. 'role',
  10. db.Unicode(32),
  11. nullable=False,
  12. default=ROLE_USER, )
  13. password_hash = db.Column('password_hash', db.Unicode(128), nullable=False)
  14. password_revision = db.Column(
  15. 'password_revision', db.SmallInteger, default=0, nullable=False)
  16. creation_time = db.Column('creation_time', db.DateTime, nullable=False)
  17. last_login_time = db.Column('last_login_time', db.DateTime)
  18. version = db.Column('version', db.Integer, default=1, nullable=False)
  19. class UserToken(db.Model):
  20. __tablename__ = 'user_token'
  21. user_token_id = db.Column('id', db.Integer, primary_key=True)
  22. user_id = db.Column(
  23. 'user_id',
  24. db.Integer,
  25. db.ForeignKey('user.id', ondelete='CASCADE'),
  26. nullable=False,
  27. index=True)
  28. token = db.Column('token', db.Unicode(36), nullable=False)
  29. note = db.Column('note', db.Unicode(128), nullable=True)
  30. enabled = db.Column('enabled', db.Boolean, nullable=False, default=True)
  31. expiration_time = db.Column('expiration_time', db.DateTime, nullable=True)
  32. creation_time = db.Column('creation_time', db.DateTime, nullable=False)
  33. last_edit_time = db.Column('last_edit_time', db.DateTime)
  34. last_usage_time = db.Column('last_usage_time', db.DateTime)
  35. version = db.Column('version', db.Integer, default=1, nullable=False)