예제 #1
0
def regions_list(version=DEFAULT_API_VERSION):
    def gen():
        return [factory.region(id=i, name=REGIONS[slug], slug=slug)
                for i, slug in enumerate(REGIONS)]

    data = app._paginated('objects', gen, len(REGIONS))
    return data
예제 #2
0
def carriers_list(version=DEFAULT_API_VERSION):
    def gen():
        return [factory.carrier(id=i, name=CARRIERS[slug], slug=slug)
                for i, slug in enumerate(CARRIERS)]

    data = app._paginated('objects', gen, len(CARRIERS))
    return data
예제 #3
0
def extension_search(version=DEFAULT_API_VERSION):
    query = request.args.get('q', '')

    num_results = 0 if query == 'empty' else 42

    extension_kw = {}
    data = app._paginated('objects', extension_generator, num_results,
                          **extension_kw)
    return data
예제 #4
0
def carriers_list(version=DEFAULT_API_VERSION):
    def gen():
        return [
            factory.carrier(id=i, name=CARRIERS[slug], slug=slug)
            for i, slug in enumerate(CARRIERS)
        ]

    data = app._paginated('objects', gen, len(CARRIERS))
    return data
예제 #5
0
파일: services.py 프로젝트: cvan/flue
def carriers_list():
    def gen():
        i = 1
        while 1:
            yield app.defaults.carrier(id=i, slug='carrier-%d' % i)
            i += 1

    data = app._paginated('objects', gen, 24)
    return data
예제 #6
0
def extension_search(version=DEFAULT_API_VERSION):
    query = request.args.get('q', '')

    num_results = 0 if query == 'empty' else 42

    extension_kw = {}
    data = app._paginated('objects', extension_generator, num_results,
                          **extension_kw)
    return data
예제 #7
0
def regions_list(version=DEFAULT_API_VERSION):
    def gen():
        return [
            factory.region(id=i, name=REGIONS[slug], slug=slug)
            for i, slug in enumerate(REGIONS)
        ]

    data = app._paginated('objects', gen, len(REGIONS))
    return data
예제 #8
0
파일: services.py 프로젝트: cvan/flue
def regions_list():
    def gen():
        i = 1
        while 1:
            yield app.defaults.region(id=i, slug='region-%d' % i)
            i += 1

    data = app._paginated('objects', gen, 24)
    return data
예제 #9
0
파일: main.py 프로젝트: cvan/flue
def installed():
    def gen():
        i = 0
        while 1:
            yield defaults.app('Purchased App', 'purchase%d' % i)
            i += 1

    query = request.args.get('q')
    data = app._paginated('objects', gen, 0 if query == 'empty' else 24)
    return data
예제 #10
0
파일: main.py 프로젝트: cvan/flue
def search():
    def gen():
        i = 0
        while 1:
            yield defaults.app('Result', 'sr%d' % i)
            i += 1

    query = request.args.get('q')
    data = app._paginated('objects', gen, 0 if query == 'empty' else 24)
    return data
예제 #11
0
def search(version=DEFAULT_API_VERSION):
    query = request.args.get('q', '')

    num_results = 0 if query == 'empty' else 42

    app_kw = {}
    if query.startswith('num-previews-'):
        app_kw['num_previews'] = int(query.split('num-previews-')[1])

    data = app._paginated('objects', app_generator, num_results, **app_kw)
    return data
예제 #12
0
파일: main.py 프로젝트: diox/flue
def multi_search(version=DEFAULT_API_VERSION):
    query = request.args.get('q', '')
    num_results = 0 if query == 'empty' else 42
    kw = {
        # The doc_type parameter in the API is singular even though it can
        # contain multiple document types, separated by a comma. It defaults to
        # webapp,website if absent.
        'doc_types': request.args.get('doc_type', 'webapp,website').split(',')
    }
    data = app._paginated('objects', multi_generator, num_results, **kw)
    return data
예제 #13
0
def search(version=DEFAULT_API_VERSION):
    query = request.args.get('q', '')

    num_results = 0 if query == 'empty' else 42

    app_kw = {}
    if query.startswith('num-previews-'):
        app_kw['num_previews'] = int(query.split('num-previews-')[1])

    data = app._paginated('objects', app_generator, num_results, **app_kw)
    return data
예제 #14
0
파일: main.py 프로젝트: diox/flue
def multi_search(version=DEFAULT_API_VERSION):
    query = request.args.get('q', '')
    num_results = 0 if query == 'empty' else 42
    kw = {
        # The doc_type parameter in the API is singular even though it can
        # contain multiple document types, separated by a comma. It defaults to
        # webapp,website if absent.
        'doc_types': request.args.get('doc_type', 'webapp,website').split(',')
    }
    data = app._paginated('objects', multi_generator, num_results, **kw)
    return data
예제 #15
0
파일: main.py 프로젝트: imclab/flue
def search():
    offset = int(request.args.get('offset', 0))
    def gen():
        i = 0
        while 1:
            nb = i + 1 + offset
            yield defaults.app('Result %d' % nb, 'sr%d' % nb)
            i += 1

    query = request.args.get('q')
    data = app._paginated('objects', gen, 0 if query == 'empty' else 42)
    return data
예제 #16
0
파일: main.py 프로젝트: cvan/flue
def category():
    def gen():
        i = 0
        while 1:
            yield defaults.app('Category Item', 'catm %d' % i)
            i += 1

    data = app._paginated('objects', gen)
    data['featured'] = [defaults.app('Creatured App', 'creat%d' % i)
                        for i in xrange(15)]
    data['collections'] = {}
    for i in xrange(2):
        c = defaults.collection('Collection', 'collection-%d' % i,
                                collection_type='featured')
        data['collections']['featured-collection-%d' % i] = c
    return data
예제 #17
0
파일: main.py 프로젝트: ngokevin/flue
def app_ratings(version=DEFAULT_API_VERSION):
    if request.method == 'POST':
        return {'error': False}

    slug = request.form.get('app') or request.args.get('app')

    data = app._paginated('objects', review_generator)
    data['info'] = {
        'slug': slug,
        'average': random.random() * 4 + 1,
    }
    data.update(factory.review_user_data(slug))

    if slug == 'has_rated':
        data['objects'][0]['is_author'] = True
        data['objects'][0]['is_flagged'] = False

    return data
예제 #18
0
파일: main.py 프로젝트: cvan/flue
def app_ratings():
    if request.method == 'POST':
        return {'error': False}

    def gen():
        i = 0
        while 1:
            yield defaults.rating()
            i += 1

    slug = request.form.get('app') or request.args.get('app')

    data = app._paginated('objects', gen)
    data['info'] = {
        'slug': slug,
        'average': random.random() * 4 + 1,
    }
    data.update(defaults.app_user_data(slug))
    return data
예제 #19
0
파일: main.py 프로젝트: imclab/flue
def category():
    def gen():
        i = 0
        while 1:
            yield defaults.app('Category Item', 'catm %d' % i)
            i += 1

    data = app._paginated('objects', gen)
    data['collections'] = [
        defaults.collection('Collection', 'collection-0',
                            collection_type=0),
        defaults.collection('Collection', 'collection-1',
                            collection_type=0),
    ]
    data['featured'] = [
        defaults.collection('Featured', 'featured', collection_type=1),
    ]
    data['operator'] = [
        defaults.collection('Operator Shelf', 'operator', collection_type=2),
    ]
    return data
예제 #20
0
def app_ratings(version=DEFAULT_API_VERSION):
    if request.method == 'POST':
        return {'error': False}

    slug = request.form.get('app') or request.args.get('app')

    if slug == 'unrated':
        return {
            'info': {
                'average': 0,
                'slug': slug,
            },
            'meta': {
                'next': None,
                'prev': None,
                'total_count': 0,
            },
            'objects': [],
        }

    data = app._paginated('objects', review_generator, slug=slug)
    data['info'] = {
        'average': random.random() * 4 + 1,
        'current_version': '2.0',
        'slug': slug,
    }
    data.update(factory.review_user_data(slug))

    if slug == 'has_rated':
        data['objects'][0]['has_flagged'] = False
        data['objects'][0]['is_author'] = True
    elif slug == 'old-reviews':
        for review in data['objects']:
            review['version'] = {
                'version': '1.0'
            }

    return data
예제 #21
0
def app_ratings(version=DEFAULT_API_VERSION):
    if request.method == 'POST':
        return {'error': False}

    slug = request.form.get('app') or request.args.get('app')

    if slug == 'unrated':
        return {
            'info': {
                'average': 0,
                'slug': slug,
            },
            'meta': {
                'next': None,
                'prev': None,
                'total_count': 0,
            },
            'objects': [],
        }

    data = app._paginated('objects', review_generator, slug=slug)
    data['info'] = {
        'average': random.random() * 4 + 1,
        'current_version': '2.0',
        'slug': slug,
    }
    data.update(factory.review_user_data(slug))

    if slug == 'has_rated':
        data['objects'][0]['has_flagged'] = False
        data['objects'][0]['is_author'] = True
    elif slug == 'old-reviews':
        for review in data['objects']:
            review['version'] = {'version': '1.0'}

    return data
예제 #22
0
def collections_list():
    if app.request.method == 'POST':
        form = app.request.form
        DB['pk'] += 1
        return {
            'title': form.get('title'),
            'description': form.get('description'),
            'id': DB['pk'],
            'apps': [],
            'collection_type': form.get('collection_type'),
            'category': form.get('category'),
            'region': form.get('region'),
            'carrier': form.get('carrier'),
        }

    def gen():
        i = 0
        while 1:
            yield app.defaults.collection('Collection', 'collection-%d' % i)
            i += 1

    query = app.request.args.get('q')
    data = app._paginated('objects', gen, 0 if query == 'empty' else 25)
    return data
예제 #23
0
def feed(version=DEFAULT_API_VERSION):
    return app._paginated('objects', None, 30, feed_factory.feed())
예제 #24
0
def langpacks():
    fxos_version = request.args.get('fxos_version')
    return app._paginated('objects', langpack_generator,
                          0 if fxos_version == 'empty' else 42)
예제 #25
0
def website_search(version=DEFAULT_API_VERSION):
    query = request.args.get('q', '')
    num_results = 0 if query == 'empty' else 42
    data = app._paginated('objects', website_generator, num_results)
    return data
예제 #26
0
def category(version=DEFAULT_API_VERSION):
    return app._paginated('objects', app_generator)
예제 #27
0
파일: main.py 프로젝트: ngokevin/flue
def search(version=DEFAULT_API_VERSION):
    offset = int(request.args.get('offset', 0))
    query = request.args.get('q')
    data = app._paginated('objects', app_generator,
                          0 if query == 'empty' else 42)
    return data
예제 #28
0
def website_search(version=DEFAULT_API_VERSION):
    query = request.args.get('q', '')
    num_results = 0 if query == 'empty' else 42
    data = app._paginated('objects', website_generator, num_results)
    return data
예제 #29
0
def installed(version=DEFAULT_API_VERSION):
    query = request.args.get('q')
    data = app._paginated('objects', app_generator,
                          0 if query == 'empty' else 42)
    return data
예제 #30
0
def feed(version=DEFAULT_API_VERSION):
    return app._paginated('objects', None, 30, feed_factory.feed())
예제 #31
0
def installed(version=DEFAULT_API_VERSION):
    query = request.args.get('q')
    data = app._paginated('objects', app_generator,
                          0 if query == 'empty' else 42)
    return data
예제 #32
0
def langpacks():
    fxos_version = request.args.get('fxos_version')
    return app._paginated('objects',
                          langpack_generator,
                          0 if fxos_version == 'empty' else 42)
예제 #33
0
def category(version=DEFAULT_API_VERSION):
    return app._paginated('objects', app_generator)