示例#1
0
文件: feed.py 项目: ngokevin/flue
def shelf(**kw):
    global counter
    counter += 1

    _carrier = carrier()['slug']
    app_count = kw.get('app_count', 6)

    data = {
        'apps': [app() for i in xrange(app_count)],
        'app_count': app_count,
        'background_image': SAMPLE_BG,
        'background_image_landing': SAMPLE_BG,
        'carrier': _carrier,
        'description': '',
        'id': counter,
        'name': '%s Op Shelf' % _carrier.replace('_', ' ').capitalize(),
        'region': 'restofworld',
        'slug': 'shelf-%d' % counter,
        'url': '/api/v2/feed/shelves/%d/' % counter
    }

    data = dict(data, **kw)

    if data['slug'] == 'shelf':
        data.update({
            'name': 'Shelf'
        })
    elif data['slug'] == 'shelf-desc':
        data.update({
            'description': rand_text(),
            'name': 'Shelf Description'
        })

    return data
示例#2
0
def shelf(**kw):
    global counter
    counter += 1

    _carrier = carrier()['slug']
    app_count = kw.get('app_count', 6)

    data = {
        'apps': [app() for i in xrange(app_count)],
        'app_count': app_count,
        'background_image': SAMPLE_BG,
        'background_image_landing': SAMPLE_BG,
        'carrier': _carrier,
        'description': '',
        'id': counter,
        'name': '%s Op Shelf' % _carrier.replace('_', ' ').capitalize(),
        'region': 'restofworld',
        'slug': 'shelf-%d' % counter,
        'url': '/api/v2/feed/shelves/%d/' % counter
    }

    data = dict(data, **kw)

    if data['slug'] == 'shelf':
        data.update({
            'name': 'Shelf'
        })
    elif data['slug'] == 'shelf-desc':
        data.update({
            'description': rand_text(),
            'name': 'Shelf Description'
        })

    return data
示例#3
0
文件: feed.py 项目: ngokevin/flue
def feed_item(**kw):
    global counter
    counter += 1

    return dict({
        'app': feed_app(),
        'brand': brand(),
        'carrier': carrier()['slug'],
        'collection': collection(),
        'id': counter,
        'item_type': random.choice(['app', 'collection', 'brand']),
        'url': '/api/v2/feed/items/%d/' % counter,
        'region': region()['slug'],
        'shelf': shelf()
    }, **kw)
示例#4
0
def feed_item(**kw):
    global counter
    counter += 1

    return dict({
        'app': feed_app(),
        'brand': brand(),
        'carrier': carrier()['slug'],
        'collection': collection(),
        'id': counter,
        'item_type': random.choice(['app', 'collection', 'brand']),
        'url': '/api/v2/feed/items/%d/' % counter,
        'region': region()['slug'],
        'shelf': shelf()
    }, **kw)
示例#5
0
def carriers_get(version=DEFAULT_API_VERSION, slug=None):
    return factory.carrier(slug=slug)
示例#6
0
 def gen():
     return [factory.carrier(id=i, name=CARRIERS[slug], slug=slug)
             for i, slug in enumerate(CARRIERS)]
示例#7
0
def carriers_get(version=DEFAULT_API_VERSION, slug=None):
    return factory.carrier(slug=slug)
示例#8
0
 def gen():
     return [
         factory.carrier(id=i, name=CARRIERS[slug], slug=slug)
         for i, slug in enumerate(CARRIERS)
     ]