Ejemplo n.º 1
0
class Post(db.Model):
    __tablename__ = "posts"

    id = db.Column("post_id", db.Integer, primary_key=True, autoincrement=True)
    author = db.Column(db.String(50), nullable=False)
    pdate = db.Column("post_date", db.DateTime, nullable=False)
    title = db.Column(db.String(50), nullable=False)
    content = db.Column(db.Text, nullable=False)
    pinned = db.Column(db.Boolean, nullable=False)
    imgFilePath = db.Column(db.Text, nullable=True)

    def __init__(self, author, title, content, pinned, path):
        self.author = author
        self.pdate = datetime.datetime.now()
        self.title = title
        self.content = content
        self.pinned = pinned
        self.imgFilePath = path

    def create(self):
        db.session.add(self)
        db.session.commit()
        return self

    def update(self, newData):
        self.data = newData
        db.session.commit()
        return self

    def delete(self):
        db.session.delete(self)
        db.session.commit()

    def __repr__(self):
        return '' % self.title
Ejemplo n.º 2
0
class Event(db.Model):
    __tablename__ = "events"

    id = db.Column("Event_ID", db.Integer, primary_key=True, autoincrement=True)
    edate = db.Column("Event_Date", db.DateTime, nullable=False)
    title = db.Column(db.String(50), nullable=False)
    desc = db.Column("Description", db.Text, nullable=False)
    location = db.Column(db.String(50), nullable=False)
    fblink = db.Column("FB_Link", db.String(50), nullable=False)

    def create(self):
        db.session.add(self)
        db.session.commit()
        return self

    def update(self, newData):
        self.data = newData
        db.session.commit()
        return self

    def delete(self):
        db.session.delete(self)
        db.session.commit()

    def __init__(self, edate, title, description, location, fblink):
        self.edate = edate
        self.title = title
        self.desc = description
        self.location = location
        self.fblink = fblink
    
    def __repr__(self):
        return '' % self.id
Ejemplo n.º 3
0
class User(db.Model):
    __tablename__ = "users"

    id = db.Column("user_id", db.Integer, primary_key=True, autoincrement=True)
    firstName = db.Column("firstName", db.String(45), nullable=False)
    lastName = db.Column("lastName", db.String(45), nullable=False)
    emailAddress = db.Column("emailAddress",
                             db.String(45),
                             unique=True,
                             nullable=False)
    password = db.Column("password", db.String(255), nullable=True)
    facebookUserID = db.Column(db.String(255), nullable=True)
    admin = db.Column("admin", db.Boolean, nullable=False)
    create_date = db.Column("create_date", db.DateTime, nullable=False)

    def __init__(self, fName, lName, email, password, fbID, admin):
        self.firstName = fName
        self.lastName = lName
        self.emailAddress = email
        self.password = password
        self.facebookUserID = fbID
        self.admin = admin
        self.create_date = datetime.datetime.now()

    def create(self):
        db.session.add(self)
        db.session.commit()
        return self

    def hash_password(self):
        self.password = generate_password_hash(self.password).decode('utf8')

    def check_password(self, password):
        return check_password_hash(self.password, password)
Ejemplo n.º 4
0
class Photo(db.Model):
    __tablename__ = "photos"

    id = db.Column("photo_id", db.Integer, primary_key=True, autoincrement=True)
    udate = db.Column("upload_date", db.DateTime, nullable=False)
    tdate = db.Column("taken_date", db.DateTime)
    path = db.Column("img_path", db.Text, nullable=False)
    physloc = db.Column("physical_location", db.String(50))
    desc = db.Column("description", db.Text)
    categories = db.Column(db.Text)

    def create(self):
        db.session.add(self)
        db.session.commit()
        return self

    def update(self, newData):
        self.data = newData
        db.session.commit()
        return self
    
    def delete(self):
        db.session.delete(self)
        db.session.commit()

    def __init__(self, tdate, path, physloc, desc, categories):
        self.udate = datetime.datetime.now()
        self.tdate = tdate
        self.path = path
        self.physloc = physloc
        self.desc = desc
        self.categories = categories

    def __repr__(self):
        return '' % self.path