Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #9
0
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
Exemple #10
0
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
Exemple #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
Exemple #12
0
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
Exemple #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
Exemple #14
0
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
Exemple #15
0
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
Exemple #16
0
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
Exemple #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
Exemple #18
0
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
Exemple #19
0
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
Exemple #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
Exemple #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
Exemple #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
Exemple #23
0
def feed(version=DEFAULT_API_VERSION):
    return app._paginated('objects', None, 30, feed_factory.feed())
Exemple #24
0
def langpacks():
    fxos_version = request.args.get('fxos_version')
    return app._paginated('objects', langpack_generator,
                          0 if fxos_version == 'empty' else 42)
Exemple #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
Exemple #26
0
def category(version=DEFAULT_API_VERSION):
    return app._paginated('objects', app_generator)
Exemple #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
Exemple #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
Exemple #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
Exemple #30
0
def feed(version=DEFAULT_API_VERSION):
    return app._paginated('objects', None, 30, feed_factory.feed())
Exemple #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
Exemple #32
0
def langpacks():
    fxos_version = request.args.get('fxos_version')
    return app._paginated('objects',
                          langpack_generator,
                          0 if fxos_version == 'empty' else 42)
Exemple #33
0
def category(version=DEFAULT_API_VERSION):
    return app._paginated('objects', app_generator)