from database import db_connection class User(db_connection.Model): __tablename__ = 'users' id = db_connection.Column(db_connection.Integer, primary_key=True, index=True) username = db_connection.Column(db_connection.String, unique=True, index=True, nullable=False) full_name = db_connection.Column(db_connection.String, nullable=False) email = db_connection.Column(db_connection.String, unique=True, index=True, nullable=False) public_key = db_connection.Column(db_connection.String, nullable=False) orgs = db_connection.relationship('Organization', back_populates='owner') files = db_connection.relationship('File', back_populates='creator') def to_dict(self): return { "id": self.id, "username": self.username, "full_name": self.full_name, "email": self.email, "public_key": self.public_key, "orgs": [{"id": org.id, "name": org.name} for org in self.orgs], "files": [{"id": file.id, "name": file.name, "file_handle": file.file_handle} for file in self.files] }