class Event(db.Model): __tablename__ = 'event' id = db.Column(db.Integer, primary_key=True, autoincrement=True) owner_id = db.Column(db.Integer, db.ForeignKey("user.id"), unique=False, nullable=False) owner = db.relationship("User", backref=db.backref("user"), foreign_keys=[owner_id], uselist=False) name = db.Column(db.String(60), unique=False, nullable=False) discrption = db.Column(db.Text, unique=False, nullable=True) timestamp = db.Column(db.DateTime, unique=False, nullable=False, default=datetime.datetime.utcnow) start_time = db.Column(db.DateTime, unique=False, nullable=True) end_time = db.Column(db.DateTime, unique=False, nullable=True) parent_id = db.Column(db.Integer, db.ForeignKey("event.id"), unique=False, nullable=True) parent = db.relationship("Event", remote_side=[id], uselist=False) #children = db.relationship("Event", backref=db.backref("event", uselist=True), foreign_keys=[parent_id]) #TODO not working event_type = db.Column(db.Enum(EventType), unique=False, nullable=False) def __repr__(self): return str(self.id) + ', ' + str(self.name) + ', ' + str( self.owner_id) + ', ' + str(self.discrption) + ', ' + str( self.timestamp) + "\n"
class UserInGroup(db.Model): __tablename__ = 'user_in_group' group_id = db.Column(db.Integer, db.ForeignKey("group.id"), primary_key=True, unique=False) group = db.relationship("Group", foreign_keys=[group_id], backref=db.backref("members", uselist=True), uselist=False) user_id = db.Column(db.Integer, db.ForeignKey("user.id"), primary_key=True, unique=False) user = db.relationship("User", foreign_keys=[user_id], backref=db.backref("groups", uselist=True), uselist=False) write = db.Column(db.Boolean, unique=False, nullable=False) admin = db.Column(db.Boolean, unique=False, nullable=False)
class Group(db.Model): __tablename__ = 'group' id = db.Column(db.Integer, primary_key=True, autoincrement=True) owner_id = db.Column(db.Integer, db.ForeignKey("user.id"), unique=False, nullable=False) owner = db.relationship("User", foreign_keys=[owner_id], backref=db.backref("owned_groups", uselist=True), uselist=False) name = db.Column(db.String(60), unique=False, nullable=False) description = db.Column(db.Text, unique=False, nullable=True) picture = db.Column(db.LargeBinary, nullable=True)
class SharedEventUser(db.Model): __tablename__ = "shared_event_user" event_id = db.Column(db.Integer, db.ForeignKey("event.id"), primary_key=True, unique=False) event = db.relationship("Event", foreign_keys=[event_id], backref=db.backref("shared_events_user", uselist=True), uselist=False) user_id = db.Column(db.Integer, db.ForeignKey("user.id"), primary_key=True, unique=False) user = db.relationship("User", foreign_keys=[user_id], backref=db.backref("shared_events", uselist=True), uselist=False) write = db.Column(db.Boolean, unique=False, nullable=False)
class SharedEventGroup(db.Model): __tablename__ = "shared_event_group" event_id = db.Column(db.Integer, db.ForeignKey("event.id"), primary_key=True, unique=False) event = db.relationship("Event", foreign_keys=[event_id], backref=db.backref("shared_events_group", uselist=True), uselist=False) group_id = db.Column(db.Integer, db.ForeignKey("group.id"), primary_key=True, unique=False) group = db.relationship("Group", foreign_keys=[group_id], backref=db.backref("shared_events", uselist=True), uselist=False) write = db.Column(db.Boolean, unique=False, nullable=False)
class RememberUser(db.Model): __tablename__ = "remember_user" user_id = db.Column(db.Integer, db.ForeignKey("user.id"), unique=False, nullable=False) user = db.relationship("User", backref=db.backref("user"), foreign_keys=[user_id], uselist=False) timestamp = db.Column(db.DateTime, unique=False, nullable=False, default=datetime.datetime.utcnow) cookie = db.Column(db.String(129), unique=False, nullable=False, primary_key=True)