예제 #1
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)
예제 #2
0
class Task(db.Model):
    """the Task class represent a single task"""
    task_id = db.Column(db.String(40), nullable=False, primary_key=True)
    task_type = db.Column(db.String(40), nullable=False, primary_key=True)
    title = db.Column(db.String(80), nullable=False, primary_key=False)
    desc = 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)
    tags = db.Column(db.JSON)
    items = db.Column(db.JSON)
    start_date = db.Column(ArrowType)
    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, desc: %s, price: %s, video_url: %s, min_to_complete: %s, start_date: %s, delay_days: %s, min_client_version_android: %s, min_client_version_ios %s>' % \
               (self.task_id, self.task_type, self.title, self.desc, self.price, self.video_url, self.min_to_complete, self.start_data, self.delay_days, self.min_client_version_android, self.min_client_version_ios)
class AppDiscovery(db.Model):
    """ the app discovery class represents a single Discoverable App """
    sid = db.Column(db.Integer(), nullable=False, primary_key=True)
    identifier = db.Column(db.String(40), nullable=False, primary_key=False)
    name = db.Column(db.String(80), nullable=False, primary_key=False)
    category_id = db.Column(db.Integer(), nullable=False, primary_key=False)
    is_active = db.Column(db.Boolean, unique=False, default=False)
    os_type = db.Column(db.String(20), primary_key=False, nullable=False)
    meta_data = db.Column(db.JSON, primary_key=False, nullable=False)
    transfer_data = db.Column(db.JSON, primary_key=False, nullable=True)

    def __repr__(self):
        return '<sid: %d, identifier: %s, name: %s, category_id: %d, meta_data: %s, transfer_data: %s>' % (
            self.sid, self.identifier, self.name, self.category_id,
            self.meta_data, self.transfer_data)
class SystemConfig(db.Model):
    """SytemConfig is a table with various configuration options that are coded into the db"""
    sid = db.Column(db.Integer(),
                    db.Sequence('sid', start=1, increment=1),
                    primary_key=True)
    block_clients_below_version_android = db.Column(
        'block_clients_below_version_android',
        db.String(100),
        nullable=False,
        primary_key=False)
    block_clients_below_version_ios = db.Column(
        'block_clients_below_version_ios',
        db.String(100),
        nullable=False,
        primary_key=False)
    update_available_below_version_android = db.Column(
        'update_available_below_version_android',
        db.String(100),
        nullable=False,
        primary_key=False)
    update_available_below_version_ios = db.Column(
        'update_available_below_version_ios',
        db.String(100),
        nullable=False,
        primary_key=False)
    categories_extra_data = db.Column(
        db.JSON)  # all sorts of extra global data pertaining to categories
예제 #5
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)
예제 #6
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)
예제 #7
0
class Task(db.Model):
    '''the Task class represent a single task'''
    task_id = db.Column(db.String(40), nullable=False, primary_key=True)
    task_type = db.Column(db.String(40), nullable=False, primary_key=True)
    title = db.Column(db.String(80), nullable=False, primary_key=False)
    desc = db.Column(db.String(80), nullable=False, primary_key=False)
    price = db.Column(db.Integer(), nullable=False, primary_key=False)
    min_to_complete = db.Column(db.Integer(), nullable=False, primary_key=False)
    provider_data = db.Column(db.JSON)
    tags = db.Column(db.JSON)
    items = db.Column(db.JSON)
    start_date = db.Column(ArrowType)
    update_at = db.Column(db.DateTime(timezone=True), server_default=db.func.now(), onupdate=db.func.now())

    def __repr__(self):
        return '<task_id: %s, task_type: %s, title: %s, desc: %s, price: %s, min_to_complete: %s, start_date>' % (self.task_id, self.task_type, self.title, self.desc, self.price, self.min_to_complete, self.start_data)
예제 #8
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)
예제 #9
0
class User(db.Model):
    '''
    the user model
    '''
    sid = db.Column(db.Integer(),
                    db.Sequence('sid', start=1, increment=1),
                    primary_key=False)
    user_id = db.Column(UUIDType(binary=False),
                        primary_key=True,
                        nullable=False)
    os_type = db.Column(db.String(10), primary_key=False, nullable=False)
    device_model = db.Column(db.String(40), primary_key=False, nullable=False)
    push_token = db.Column(db.String(200), primary_key=False, nullable=True)
    time_zone = db.Column(db.Integer(), primary_key=False, nullable=False)
    device_id = db.Column(db.String(40), primary_key=False, nullable=True)
    created_at = db.Column(db.DateTime(timezone=True),
                           server_default=db.func.now())
    onboarded = db.Column(db.Boolean, unique=False, default=False)

    def __repr__(self):
        return '<sid: %s, user_id: %s, os_type: %s, device_model: %s, push_token: %s, time_zone: %s, device_id: %s, onboarded: %s>' % (
            self.sid, self.user_id, self.os_type, self.device_model,
            self.push_token, self.time_zone, self.device_id, self.onboarded)
예제 #10
0
class BackupQuestion(db.Model):
    """the BackupQuestion model represents a single backup question. these are essentially hardcoded into the db.
    """
    sid = db.Column(db.Integer(),
                    db.Sequence('sid', start=1, increment=1),
                    primary_key=True)
    question_text = db.Column('question_text', db.String(300), unique=True)
    updated_at = db.Column(db.DateTime(timezone=True),
                           server_default=db.func.now(),
                           onupdate=db.func.now())

    def __repr__(self):
        return '<sid: %s, question_text: %s' \
               ' updated_at: %s>' % (self.sid, self.question_text, self.updated_at)
예제 #11
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)
예제 #12
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)
예제 #13
0
class Offer(db.Model):
    """the Offer class represent a single offer"""
    offer_id = db.Column(db.String(40), nullable=False, primary_key=True)
    offer_type = db.Column(db.String(40), nullable=False, primary_key=False)
    offer_type_image_url = db.Column(db.String(100), nullable=False, primary_key=False)
    offer_domain = db.Column(db.String(40), nullable=False, primary_key=False)
    is_active = db.Column(db.Boolean, unique=False, default=False)
    title = db.Column(db.String(80), nullable=False, primary_key=False)
    desc = db.Column(db.String(1000), nullable=False, primary_key=False)
    image_url = db.Column(db.String(100), nullable=False, primary_key=False)
    kin_cost = db.Column(db.Integer(), nullable=False, primary_key=False)
    address = db.Column(db.String(80), nullable=False, primary_key=False)
    update_at = db.Column(db.DateTime(timezone=True), server_default=db.func.now(), onupdate=db.func.now())
    provider_data = db.Column(db.JSON)
    min_client_version_ios = db.Column(db.String(80), nullable=True, primary_key=False)
    min_client_version_android = db.Column(db.String(80), nullable=True, primary_key=False)
    unavailable_reason = None
    cannot_buy_reason = None

    def __repr__(self):
        return '<offer_id: %s, offer_type: %s, title: %s, desc: %s, kin_cost: %s, is_active: %s, min_client_version_ios: %s, min_client_version_android: %s>' % \
               (self.offer_id, self.offer_type, self.title, self.desc, self.kin_cost, self.is_active, self.min_client_version_ios, self.min_client_version_android)
예제 #14
0
class Offer(db.Model):
    '''the Offer class represent a single offer'''
    offer_id = db.Column(db.String(40), nullable=False, primary_key=True)
    offer_type = db.Column(db.String(40), nullable=False, primary_key=False)
    offer_type_image_url = db.Column(db.String(100),
                                     nullable=False,
                                     primary_key=False)
    offer_domain = db.Column(db.String(40), nullable=False, primary_key=False)
    is_active = db.Column(db.Boolean, unique=False, default=False)
    title = db.Column(db.String(80), nullable=False, primary_key=False)
    desc = db.Column(db.String(500), nullable=False, primary_key=False)
    image_url = db.Column(db.String(100), nullable=False, primary_key=False)
    kin_cost = db.Column(db.Integer(), nullable=False, primary_key=False)
    address = db.Column(db.String(80), nullable=False, primary_key=False)
    update_at = db.Column(db.DateTime(timezone=True),
                          server_default=db.func.now(),
                          onupdate=db.func.now())
    provider_data = db.Column(db.JSON)

    def __repr__(self):
        return '<offer_id: %s, offer_type: %s, title: %s, desc: %s, kin_cost: %s, is_active: %s>' % (
            self.offer_id, self.offer_type, self.title, self.desc,
            self.kin_cost, self.is_active)
예제 #15
0
class AppDiscoveryCategory(db.Model):
    """ the app discovery category represents a single App Category """
    category_id = db.Column(db.Integer(), nullable=False, primary_key=True)
    category_name = db.Column(db.String(80), nullable=False, primary_key=False)