Ejemplo n.º 1
0
class Order(db.Model):

    __tablename__ = 'orders'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(255), nullable=False)
    price = db.Column(db.Integer, nullable=False)
    kind = db.Column(db.String(255), nullable=False)
    feature = db.Column(db.String(255), nullable=True)
Ejemplo n.º 2
0
class User(db.Model):
    __tablename__ = 'users'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(255), nullable=False)
    created_at = db.Column(db.DateTime, nullable=False, default=datetime.now)
    updated_at = db.Column(db.DateTime,
                           nullable=False,
                           default=datetime.now,
                           onupdate=datetime.now)
Ejemplo n.º 3
0
class Entry(db.Model):
    __tablename__ = 'entries'
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(), nullable=False)
    body = db.Column(db.String(), nullable=False)
    posted_by = db.Column(db.String(), nullable=False)
    created_at = db.Column(db.DateTime, nullable=False, default=datetime.now)
    updated_at = db.Column(db.DateTime,
                           nullable=False,
                           default=datetime.now,
                           onupdate=datetime.now)

    def __init__(self, posted_by, title, body):
        self.title = title
        self.body = body
        self.posted_by = posted_by if posted_by else 'Anonymous'

    def save(self):
        db.session.add(self)
        db.session.commit()
Ejemplo n.º 4
0
class Info(db.Model):

    __tablename__ = 'infos'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(255))
    subject = db.Column(db.String(255))
    affiliation = db.Column(db.String(255))
    email = db.Column(db.String(255))
    contents = db.Column(db.String(600))
    created_at = db.Column(db.DateTime, nullable=False, default=datetime.now)

    # updated_at = db.Column(db.DateTime, nullable=False, default=datetime.now, onupdate=datetime.now)

    def get_detail(self):
        return {
            'id': self.id,
            'name': self.name,
            'subject': self.subject,
            'affiliation': self.affiliation,
            'email': self.email,
            'contents': self.contents,
            'created_at': self.created_at
        }