class UsersRoles(db.Model): __tablename__ = 'users_roles' id = db.Column(db.Integer(), primary_key=True) user_id = db.Column(db.Integer(), db.ForeignKey('users.id', ondelete='CASCADE')) role_id = db.Column(db.Integer(), db.ForeignKey('roles.id', ondelete='CASCADE'))
class FriendshipInvite(db.Model): __tablename__ = 'friendship_invites' id = db.Column(db.Integer(), primary_key=True) friender_id = db.Column(db.Integer(), db.ForeignKey('users.id', ondelete='CASCADE'), nullable=False) friender = db.relationship("User", foreign_keys=[friender_id], back_populates="friendship_invites") # info about the invite recipient, who may or may already already # have an account (e.g. 0) friendee_id = db.Column(db.Integer(), db.ForeignKey('users.id', ondelete='CASCADE'), nullable=True) # this is null or 0 if # friendee doesn't yet have # account # can be null if an existing account friendee_email = db.Column(db.String(50), nullable=True, server_default='') friendee = db.relationship("User", foreign_keys=[friendee_id], back_populates="cofriendship_invites") # if friendship is confirmed confirmed_at = db.Column(db.DateTime(), nullable=True) invited_at = db.Column(db.DateTime(), nullable=True)
class GraphRevision(db.Model): __tablename__ = 'graph_revisions' id = db.Column(db.Integer(), primary_key=True) nodes = db.Column(db.String(10 * 1000), nullable=False, server_default='') edges = db.Column(db.String(10 * 1000), nullable=False, server_default='') graph_id = db.Column(db.Integer(), db.ForeignKey('graphs.id')) graph = db.relationship('Graph', foreign_keys="GraphRevision.graph_id") previous_revision_id = db.Column(db.Integer(), db.ForeignKey('graph_revisions.id')) timestamp = db.Column(db.DateTime()) author_id = db.Column(db.Integer(), db.ForeignKey('users.id')) author = db.relationship('User', foreign_keys=[author_id]) def string(self): nodes = pickle.loads(str(self.nodes)) edges = pickle.loads(str(self.edges)) rv = "" rv += "\n".join('Node label: ' + str(node['label']) + "\nNode details: " + str(node['detailed']) + "\n" for node in nodes) rv += "\n".join('Edge detail: ' + str(edge['detailed']) for edge in edges) return rv
class Friendship(db.Model): __tablename__ = 'friendships' id = db.Column(db.Integer(), primary_key=True) friender_id = db.Column(db.Integer(), db.ForeignKey('users.id', ondelete='CASCADE')) friendee_id = db.Column(db.Integer(), db.ForeignKey('users.id', ondelete='CASCADE')) friender = db.relationship("User", foreign_keys=[friender_id], back_populates="friendships") friendee = db.relationship("User", foreign_keys=[friendee_id], back_populates="cofriendships")
class GraphViewRevision(db.Model): __tablename__ = 'graph_view_revisions' id = db.Column(db.Integer(), primary_key=True) graph_id = db.Column(db.Integer(), db.ForeignKey('graphs.id')) graph = db.relationship('Graph', foreign_keys=graph_id) author_id = db.Column(db.Integer(), db.ForeignKey('users.id')) author = db.relationship('User', foreign_keys=author_id) nodes = db.Column(db.String(10 * 1000), nullable=False, server_default='') edges = db.Column(db.String(10 * 1000), nullable=False, server_default='') timestamp = db.Column(db.DateTime())
class Codes_T(db.Model): __tablename__ = 'Codes_T' id = db.Column(db.Integer(), primary_key=True) codenumber = db.Column(db.String(50), nullable=False, server_default=u'', unique=True) # for @roles_accepted()
class Role(db.Model): __tablename__ = 'roles' id = db.Column(db.Integer(), primary_key=True) name = db.Column(db.String(50), nullable=False, server_default=u'', unique=True) # for @roles_accepted() label = db.Column(db.Unicode(255), server_default=u'') # for display purposes
class Graph(db.Model): __tablename__ = 'graphs' id = db.Column(db.Integer(), primary_key=True) name = db.Column(db.String(50), nullable=False, server_default=u'') description = db.Column(db.String(1000), nullable=False, server_default=u'') # Relationships owners = db.relationship('User', secondary='users_graphs_owner', backref=db.backref('graphs_owned', lazy='dynamic')) helpers = db.relationship('User', secondary='users_graphs_helpers', backref=db.backref('graphs_helping', lazy='dynamic')) revisions = db.relationship('GraphRevision', foreign_keys="GraphRevision.graph_id") views = db.relationship('GraphViewRevision', foreign_keys="GraphViewRevision.graph_id") current_revision_id = db.Column(db.Integer(), db.ForeignKey('graph_revisions.id')) current_revision = db.relationship('GraphRevision', foreign_keys=[current_revision_id])
class Projects(db.Model): __tablename__ = 'projects' id = db.Column(db.Integer(), primary_key=True) url = db.Column(db.String(50), nullable=False, unique=True) json_http = db.Column(db.Text, nullable=True) json_https = db.Column(db.Text, nullable=True) json_last_updated = db.Column(db.DateTime()) def __init__(self,url,json_http,json_https,json_last_updated): self.url = url self.json_http = json_http self.json_https = json_https self.json_last_updated = json_last_updated
class UsersGraphsHelpers(db.Model): __tablename__ = 'users_graphs_helpers' id = db.Column(db.Integer(), primary_key=True) user_id = db.Column(db.Integer(), db.ForeignKey('users.id', ondelete='CASCADE')) graph_id = db.Column(db.Integer(), db.ForeignKey('graphs.id', ondelete='CASCADE'))