Exemple #1
0
def demographics(request, date_start, date_end):
    """AJAX action returning an OS/locale summary."""
    opinions = Opinion.objects.between(date_start, date_end).filter(
        product=request.default_app.id,
        version=simplify_version(LATEST_BETAS[request.default_app]))
    data = {'demo': stats.demographics(qs=opinions)}
    return jingo.render(request, 'dashboard/demographics.html', data)
Exemple #2
0
def demographics(request, date_start, date_end):
    """AJAX action returning an OS/locale summary."""
    opinions = Opinion.objects.between(date_start, date_end).filter(
        product=DASH_PROD.id)
    # TODO use real product here
    data = {'demo': stats.demographics(qs=opinions)}
    return jingo.render(request, 'dashboard/demographics.html', data)
Exemple #3
0
    try:
        (opinions, form) = _get_results(request)
    except SearchError, e:
        return jingo.render(request, 'search/unavailable.html',
                            {'search_error': e}, status=500)

    page = form.data.get('page', 1)

    data = {'form': form}
    pp = settings.SEARCH_PERPAGE

    if opinions:
        pager = Paginator(opinions, pp)
        # If page request (9999) is out of range, deliver last page of results.
        try:
            data['page'] = pager.page(page)
        except (EmptyPage, InvalidPage):
            data['page'] = pager.page(pager.num_pages)

        data['opinions'] = data['page'].object_list
        data['sent'] = stats.sentiment(qs=opinions)
        data['demo'] = stats.demographics(qs=opinions)

        #frequent_terms = Term.objects.frequent(
        #    opinions=(o.id for o in opinions))[:settings.TRENDS_COUNT]
        #data['terms'] = stats.frequent_terms(qs=frequent_terms)

    template = 'search/%ssearch.html' % (
        'mobile/' if request.mobile_site else '')
    return jingo.render(request, template, data)