Exemplo n.º 1
0
class Order(db.Model):
    '''the Order class represent a single order. 

       orders are generated when a client wishes to buy an offer.
       orders are time-limited and expire after a while.
    '''
    order_id = db.Column(db.String(len(KINIT_MEMO_PREFIX) + ORDER_ID_LENGTH),
                         primary_key=True,
                         nullable=False)
    offer_id = db.Column('offer_id',
                         db.String(40),
                         db.ForeignKey("offer.offer_id"),
                         primary_key=False,
                         nullable=False)
    user_id = db.Column('user_id',
                        UUIDType(binary=False),
                        db.ForeignKey("user.user_id"),
                        primary_key=False,
                        nullable=False)
    kin_amount = db.Column(db.Integer(), nullable=False, primary_key=False)
    address = db.Column(db.String(80), nullable=False, primary_key=False)
    created_at = db.Column(ArrowType)

    def __repr__(self):
        return '<order_id: %s, offer_id: %s, user_id: %s, kin_amount: %s, created_at: %s>' % (
            self.order_id, self.offer_id, self.user_id, self.kin_amount,
            self.created_at)
Exemplo n.º 2
0
class BlackhawkOffer(db.Model):
    """the BlackhawkOffer class represent a single offer from the OmniCodes API.

    Offers can be bought into cards with money. The merchant code and merchant template id
    are listed using Blackhawk's API requests get_merchants_api and get_merchant_api.
    """
    offer_id = db.Column('offer_id',
                         db.String(40),
                         db.ForeignKey("offer.offer_id"),
                         primary_key=True,
                         nullable=False)
    merchant_code = db.Column(
        db.String(40), nullable=False)  # used to identify a card provider
    merchant_template_id = db.Column(
        db.String(40), nullable=False
    )  # used to identify a specific card offered by the provider
    batch_size = db.Column(
        db.Integer, default=1,
        nullable=False)  # how many cards should be ordered at once in an order
    denomination = db.Column(
        db.Integer,
        nullable=False)  # the USD value loaded onto each ordered card
    minimum_threshold = db.Column(
        db.Integer,
        nullable=False)  # the threshold below a new batch should be ordered
    updated_at = db.Column(db.DateTime(timezone=True),
                           server_default=db.func.now(),
                           onupdate=db.func.now())

    def __repr__(self):
        return '<offer_id: %s, merchant_code: %s, merchant_template_id: %s, batch_size: %s, denomination: %s, minimum_threshold: %s, updated_at: %s>' % (
            self.offer_id, self.merchant_code, self.merchant_template_id,
            self.batch_size, self.denomination, self.processed,
            self.minimum_threshold, self.updated_at)
Exemplo n.º 3
0
class Transaction(db.Model):
    '''
    kin transactions
    '''
    user_id = db.Column('user_id',
                        UUIDType(binary=False),
                        db.ForeignKey("user.user_id"),
                        primary_key=False,
                        nullable=False)
    tx_hash = db.Column(db.String(100), nullable=False, primary_key=True)
    amount = db.Column(db.Integer(), nullable=False, primary_key=False)
    incoming_tx = db.Column(db.Boolean, unique=False,
                            default=False)  # are the moneys coming or going
    remote_address = db.Column(db.String(100),
                               nullable=False,
                               primary_key=False)
    tx_info = db.Column(db.JSON)
    update_at = db.Column(db.DateTime(timezone=True),
                          server_default=db.func.now(),
                          onupdate=db.func.now())

    def __repr__(self):
        return '<tx_hash: %s, user_id: %s, amount: %s, remote_address: %s, incoming_tx: %s, tx_info: %s,  update_at: %s>' % (
            self.tx_hash, self.user_id, self.amount, self.remote_address,
            self.incoming_tx, self.tx_info, self.update_at)
Exemplo n.º 4
0
class Task2(db.Model):
    """the Task class represent a single task"""
    category_id = db.Column('category_id', db.String(40), db.ForeignKey("category.category_id"), primary_key=False, nullable=False)
    task_id = db.Column(db.String(40), nullable=False, primary_key=True)
    position = db.Column(db.Integer(), nullable=False, primary_key=False) # -1 for ad-hoc tasks. multiple tasks can have -1.
    task_type = db.Column(db.String(40), nullable=False, primary_key=True)
    title = db.Column(db.String(80), nullable=False, primary_key=False)
    description = db.Column(db.String(200), nullable=False, primary_key=False)
    price = db.Column(db.Integer(), nullable=False, primary_key=False)
    video_url = db.Column(db.String(100), nullable=True, primary_key=False)
    min_to_complete = db.Column(db.Float(), nullable=False, primary_key=False)
    provider_data = db.Column(db.JSON)
    excluded_country_codes = db.Column(db.JSON, default=[])
    tags = db.Column(db.JSON)
    items = db.Column(db.JSON)
    task_start_date = db.Column(ArrowType, nullable=True)  # governs when the task is available (only used in ad-hoc tasks)
    task_expiration_date = db.Column(ArrowType, nullable=True)  # a task with expiration is an ad-hoc task
    update_at = db.Column(db.DateTime(timezone=True), server_default=db.func.now(), onupdate=db.func.now())
    delay_days = db.Column(db.Integer(), nullable=False, primary_key=False)
    min_client_version_android = db.Column(db.String(80), nullable=False, primary_key=False)
    min_client_version_ios = db.Column(db.String(80), nullable=False, primary_key=False)
    post_task_actions = db.Column(db.JSON)

    def __repr__(self):
        return '<task_id: %s, task_type: %s, title: %s' % (self.task_id, self.task_type, self.title)
Exemplo n.º 5
0
class UserAppData(db.Model):
    '''
    the user app data model tracks the version of the app installed @ the client
    '''
    user_id = db.Column('user_id', UUIDType(binary=False), db.ForeignKey("user.user_id"), primary_key=True, nullable=False)
    app_ver = db.Column(db.String(40), primary_key=False, nullable=False)
    update_at = db.Column(db.DateTime(timezone=False), server_default=db.func.now(), onupdate=db.func.now())
    completed_tasks = db.Column(db.JSON)
Exemplo n.º 6
0
class UserTaskResults(db.Model):
    '''
    the user task results
    '''
    user_id = db.Column('user_id', UUIDType(binary=False), db.ForeignKey("user.user_id"), primary_key=True, nullable=False)
    task_id = db.Column(db.String(40), nullable=False, primary_key=True)
    results = db.Column(db.JSON)
    update_at = db.Column(db.DateTime(timezone=False), server_default=db.func.now(), onupdate=db.func.now())
Exemplo n.º 7
0
class P2PTransaction(db.Model):
    """
    p2p transactions: between users
    """
    sender_user_id = db.Column('sender_user_id', UUIDType(binary=False), db.ForeignKey("user.user_id"), unique=False, nullable=False)
    receiver_user_id = db.Column('receiver_user_id', UUIDType(binary=False), db.ForeignKey("user.user_id"), unique=False, nullable=True)
    receiver_app_sid = db.Column('receiver_app_sid', db.Integer, db.ForeignKey("app_discovery.sid"), unique=False, nullable=True)
    tx_hash = db.Column(db.String(100), nullable=False, primary_key=True)
    amount = db.Column(db.Integer(), nullable=False, primary_key=False)
    sender_address = db.Column(db.String(60), db.ForeignKey("user.public_address"), nullable=False, unique=False)
    receiver_address = db.Column('receiver_address', db.String(60), nullable=False, unique=False)
    update_at = db.Column(db.DateTime(timezone=True), server_default=db.func.now(), onupdate=db.func.now())

    def __repr__(self):
        return '<p2ptx_hash: %s, sender_user_id: %s, receiver_user_id: %s, ' \
               'amount: %s, sender_address: %s, receiver_address: %s, update_at: %s>' % (self.tx_hash, self.sender_user_id, self.receiver_user_id,
                                                                                        self.amount, self.sender_address, self.receiver_address, self.update_at)
Exemplo n.º 8
0
class Good(db.Model):
    '''the Good class represent a single goods (as in, the singular of Goods). 

       Goods are pre-populated into the db and have a limited number of instances.
       Each good instance is a row in the db.  
    '''
    sid = db.Column(db.Integer(), db.Sequence('sid', start=1, increment=1), primary_key=True)
    offer_id = db.Column('offer_id', db.String(40), db.ForeignKey("offer.offer_id"), primary_key=False, nullable=False, unique=False)
    #order_id = db.Column('order_id', db.String(config.ORDER_ID_LENGTH), db.ForeignKey("order.order_id"), primary_key=False, nullable=True, unique=True)
    # TODO the order_id should be a foreign key, but that implies that orders are created BEFORE the good is allocated. this
    # needs to be improved somehow.
    order_id = db.Column(db.String(40), primary_key=False, nullable=True, unique=True)
    value = db.Column(db.JSON(), nullable=False)
    good_type = db.Column(db.String(40), primary_key=False, nullable=False)
    tx_hash = db.Column('tx_hash', db.String(100), db.ForeignKey("transaction.tx_hash"), primary_key=False, nullable=True)
    created_at = db.Column(ArrowType)
    updated_at = db.Column(db.DateTime(timezone=True), server_default=db.func.now(), onupdate=db.func.now())

    def __repr__(self):
        return '<sid: %s, offer_id: %s, order_id: %s, type: %s, tx_hash: %s, created_at: %s, updated_at: %s>' % (self.sid, self.offer_id, self.order_id, self.good_type, self.tx_hash, self.created_at, self.updated_at)
Exemplo n.º 9
0
class Transaction(db.Model):
    '''
    kin transactions
    '''
    user_id = db.Column('user_id', UUIDType(binary=False), db.ForeignKey("user.user_id"), primary_key=True, nullable=False)
    tx_hash = db.Column(db.String(40), nullable=False, primary_key=True)
    amount = db.Column(db.Integer(), nullable=False, primary_key=False)
    update_at = db.Column(db.DateTime(timezone=False), server_default=db.func.now(), onupdate=db.func.now())

    def __repr__(self):
        return '<tx_hash: %s, user_id: %s, amount: %s, desc: %s, update_at: %s>' % (self.tx_hash, self.user_id, self.amount, self.update_at)
class PushAuthToken(db.Model):
    """the PushAuth class hold data related to the push-authentication mechanism.
    """

    user_id = db.Column('user_id',
                        UUIDType(binary=False),
                        db.ForeignKey("user.user_id"),
                        primary_key=True,
                        nullable=False)
    authenticated = db.Column(db.Boolean, unique=False, default=False)
    send_date = db.Column(ArrowType)
    ack_date = db.Column(ArrowType)
    auth_token = db.Column(UUIDType(binary=False), unique=True, nullable=False)
    updated_at = db.Column(db.DateTime(timezone=True),
                           server_default=db.func.now(),
                           onupdate=db.func.now())

    def __repr__(self):
        return '<user_id: %s, authenticated: %s, send_date: %s, ack_date: %s, token: %s, updated_at: %s' % (
            self.user_id, self.authenticated, self.send_date, self.ack_date,
            self.auth_token, self.updated_at)
class TruexBlacklistedUser(db.Model):
    """list of users that are manually blacklisted from getting truex tasks. not expecting a lof of these"""
    user_id = db.Column('user_id', UUIDType(binary=False), db.ForeignKey("user.user_id"), primary_key=True, nullable=False)

    def __repr__(self):
        return '<user_id: %s>' % self.user_id