1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-22 21:14:18 +00:00
pds-2021-g2-nest/nest_backend/database/tables/User.py

20 lines
675 B
Python
Raw Normal View History

"""
This module defines the User database class.
"""
2021-05-07 17:46:14 +00:00
from ..base import ext
2021-05-07 17:46:14 +00:00
class User(ext.Model):
__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)
# 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")
def to_json(self):
return {'email': self.email, 'username': self.username, 'isAdmin': self.isAdmin}