예제 #1
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(30), unique=True, nullable=False)
    name = db.Column(db.String(60), unique=False, nullable=True)
    email = db.Column(db.String(60), unique=False, nullable=True)
    password_hash = db.Column(db.String(129), unique=False, nullable=False)
    salt = db.Column(db.String(128), unique=False, nullable=False)
    profile_picture = db.Column(db.LargeBinary, nullable=True)

    def __repr__(self):
        return str(self.id) + ', ' + str(self.username) + ', ' + str(
            self.name) + ', ' + str(self.email) + ', ' + str(
                self.password_hash) + ', ' + str(self.salt) + "\n"
예제 #2
0
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"
예제 #3
0
class User(db.Model):
    __tablename__ = 'user'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    username = db.Column(db.String(30), unique=True, nullable=False)
    name = db.Column(db.String(60), unique=False, nullable=True)
    email = db.Column(db.String(60), unique=False, nullable=True)
    password_hash = db.Column(db.String(129), unique=False, nullable=False)
    salt = db.Column(db.String(128), unique=False, nullable=False)
    profile_picture = db.Column(db.LargeBinary, nullable=True)
    events = db.relationship("Event",
                             backref=db.backref("event", uselist=True))

    def __repr__(self):
        return str(self.id) + ', ' + str(self.username) + ', ' + str(
            self.name) + ', ' + str(self.email) + ', ' + str(
                self.password_hash) + ', ' + str(self.salt) + "\n"
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)
예제 #5
0
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)