Ejemplo n.º 1
0
class Payment(db.Model):
    __tablename__ = 'payments'
    id = db.Column(db.Integer(), primary_key=True)
    ipn_id = db.Column(db.String(64), unique=True)
    txn_id = db.Column(db.String(64), unique=True)
    status = db.Column(db.String(64))
    status_text = db.Column(db.String(128))
    currency1 = db.Column(db.String(32))
    currency2 = db.Column(db.String(32))
    amount1 = db.Column(db.Integer())
    amount2 = db.Column(db.Integer())
    fee = db.Column(db.String(50))
    buyer_name = db.Column(db.String(64))
    email = db.Column(db.String(64))
    item_name = db.Column(db.String(64))
    item_number = db.Column(db.String(64))
    send_tx = db.Column(db.String(64))
    recieved_amount = db.Column(db.String(64))
    recieved_confirms = db.Column(db.String(64))
    created_at = db.Column(db.DateTime, default=datetime.utcnow)
    updated_at = db.Column(db.DateTime, default=datetime.utcnow)
    is_complete = db.Column('is_complete', db.Boolean(), nullable=False, server_default='0')

    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))

    def __repr__(self):
        return f"<Payment {self.txn_id} {self.amount2} {self.currency2}>"
Ejemplo n.º 2
0
class UserRoles(db.Model):
    __tablename__ = 'user_roles'
    id = db.Column(db.Integer(), primary_key=True)
    user_id = db.Column(db.Integer(),
                        db.ForeignKey('user.id', ondelete='CASCADE'))
    role_id = db.Column(db.Integer(),
                        db.ForeignKey('roles.id', ondelete='CASCADE'))
Ejemplo n.º 3
0
class Role(db.Model):
    __tablename__ = 'roles'
    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.String(50), unique=True)

    def __repr__(self):
        return '<Role {}>'.format(self.name)
Ejemplo n.º 4
0
class Feedback(db.Model):
    __tablename__ = 'feedbacks'
    id = db.Column(db.Integer(), primary_key=True)
    name = db.Column(db.String(64))
    email = db.Column(db.String(64))
    subject = db.Column(db.Text())
    message = db.Column(db.Text())
    created_at = db.Column(db.DateTime, default=datetime.utcnow)

    def __repr__(self):
        return f"<Feedback {self.id} {self.subject} from {self.name}>"
Ejemplo n.º 5
0
class Announcement(db.Model):
    __tablename__ = "announcements"
    id = db.Column(db.Integer(), primary_key=True)
    title = db.Column(db.String(64))
    message = db.Column(db.Text())
    created_at = db.Column(db.DateTime, default=datetime.utcnow)

    def __repr__(self):
        return f"<Announcement {self.id} {self.title} from {self.created_at}>"

    @property
    def serialize(self):
        """Return object data in easily serializeable format"""
        return {
            'id': self.id,
            'created_at': self.created_at.timestamp(),
            'title': self.title,
            'message': self.message
        }