Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 5
0
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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 8
0
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
Ejemplo n.º 9
0
Archivo: main.py Proyecto: 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
Ejemplo n.º 10
0
Archivo: main.py Proyecto: 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
Ejemplo n.º 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
Ejemplo n.º 12
0
Archivo: main.py Proyecto: 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
Ejemplo n.º 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
Ejemplo n.º 14
0
Archivo: main.py Proyecto: 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
Ejemplo n.º 15
0
Archivo: main.py Proyecto: 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
Ejemplo n.º 16
0
Archivo: main.py Proyecto: 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
Ejemplo n.º 17
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')

    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
Ejemplo n.º 18
0
Archivo: main.py Proyecto: 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
Ejemplo n.º 19
0
Archivo: main.py Proyecto: 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 23
0
def feed(version=DEFAULT_API_VERSION):
    return app._paginated('objects', None, 30, feed_factory.feed())
Ejemplo n.º 24
0
def langpacks():
    fxos_version = request.args.get('fxos_version')
    return app._paginated('objects', langpack_generator,
                          0 if fxos_version == 'empty' else 42)
Ejemplo n.º 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
Ejemplo n.º 26
0
def category(version=DEFAULT_API_VERSION):
    return app._paginated('objects', app_generator)
Ejemplo n.º 27
0
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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 30
0
def feed(version=DEFAULT_API_VERSION):
    return app._paginated('objects', None, 30, feed_factory.feed())
Ejemplo n.º 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
Ejemplo n.º 32
0
def langpacks():
    fxos_version = request.args.get('fxos_version')
    return app._paginated('objects',
                          langpack_generator,
                          0 if fxos_version == 'empty' else 42)
Ejemplo n.º 33
0
def category(version=DEFAULT_API_VERSION):
    return app._paginated('objects', app_generator)