2021-04-21 16:47:18 +00:00
|
|
|
"""
|
|
|
|
This module defines the User database class.
|
|
|
|
"""
|
|
|
|
|
2021-05-07 17:46:14 +00:00
|
|
|
from ..base import ext
|
2021-04-21 16:47:18 +00:00
|
|
|
|
|
|
|
|
2021-05-07 17:46:14 +00:00
|
|
|
class User(ext.Model):
|
2021-04-21 16:47:18 +00:00
|
|
|
__tablename__ = "user"
|
2021-05-07 17:46:14 +00:00
|
|
|
email = ext.Column(ext.String, primary_key=True)
|
|
|
|
username = ext.Column(ext.String, nullable=False)
|
|
|
|
password = ext.Column(ext.LargeBinary, nullable=False)
|
|
|
|
isAdmin = ext.Column(ext.Boolean, default=False)
|
2021-04-21 16:47:18 +00:00
|
|
|
# Relationships
|
2021-05-07 17:46:14 +00:00
|
|
|
owner_of = ext.relationship("Repository", back_populates="owner", cascade="all, delete")
|
|
|
|
authorizations = ext.relationship("Authorization", back_populates="user", cascade="all, delete")
|
2021-04-25 13:41:27 +00:00
|
|
|
|
|
|
|
def to_json(self):
|
|
|
|
return {'email': self.email, 'username': self.username, 'isAdmin': self.isAdmin}
|