2021-04-21 16:47:18 +00:00
|
|
|
"""
|
|
|
|
This module defines the User database class.
|
|
|
|
"""
|
|
|
|
|
|
|
|
from ..base import Base
|
|
|
|
|
|
|
|
|
|
|
|
class User(Base.Model):
|
|
|
|
__tablename__ = "user"
|
|
|
|
email = Base.Column(Base.String, primary_key=True)
|
|
|
|
username = Base.Column(Base.String, nullable=False)
|
|
|
|
password = Base.Column(Base.LargeBinary, nullable=False)
|
|
|
|
isAdmin = Base.Column(Base.Boolean, default=False)
|
|
|
|
# Relationships
|
2021-05-01 12:25:50 +00:00
|
|
|
owner_of = Base.relationship("Repository", back_populates="owner", cascade="all, delete")
|
|
|
|
authorizations = Base.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}
|