def search():
    """
    Renders the search results page.
    """
    context = helpers.get_context(request)
    dbconnection = database.DatabaseConnection()
    dbconnection.connect()
    if context.get('query'):
        query_index = database.build_mongo_index_query(input=context['query'])
        #flash('query: '+str(mongo_query), category='text-info')
        context['query_index'] = query_index
        if query_index != None:
            cursor, cursor_count = database.query_mongo(query=query_index, collection=settings.COLLECTION_INDEX, db=dbconnection)
            context['cursor'] = cursor
            context['cursor_count'] = cursor_count
            query_pages, query_pages_hits = database.build_mongo_pages_query(input=cursor)
            if (query_pages_hits != {}):
                context['query_pages'] = query_pages
                context['query_pages_hits'] = query_pages_hits
                documents, documents_count = database.query_mongo(query=query_pages, collection=settings.COLLECTION_DOCUMENTS, db=dbconnection, sort=context['sort'], number_of_results=context['results'], order=context['order'])
                context['documents'] = documents
                context['documents_count'] = documents_count
                if(context['documents_count'] == 0):
                    no_results()
            else:
                no_results()
        else:
            no_results()
    return render_template("search.html", context=context)
Exemple #2
0
def entity_article_functional(request, level, slug, id, format):
    c = get_context(request)
    entity = Entity.objects.get(level=level,
                                slug=slug,
                                language=c['LANGUAGE_CODE'])
    return entities_show_policy(
        request, c, entity, id, '',
        _generator('gastosf-%s-%s-%s' % (level, slug, id), format,
                   write_entity_functional_breakdown))
Exemple #3
0
def entity_income(request, level, slug, format):
    c = get_context(request)
    entity = Entity.objects.get(level=level,
                                slug=slug,
                                language=c['LANGUAGE_CODE'])
    return entities_show_helper(
        request, c, entity,
        _generator('ingresos-%s-%s' % (level, slug), format,
                   write_entity_income_breakdown))
Exemple #4
0
def entity_article_income(request, level, slug, id, format):
    c = get_context(request)
    entity = Entity.objects.get(level=level,
                                slug=slug,
                                language=c['LANGUAGE_CODE'])
    return entities_show_article(
        request, c, entity, id, '', 'income',
        _generator('ingresos-%s-%s-%s' % (level, slug, id), format,
                   write_economic_article_income_breakdown))
def spider():
    """
    Get requests renders the spider dashboard page.
    Post requests add a spider to the queue.
    """
    if request.method == 'GET':
        context = helpers.get_context(request)
        return render_template("spider.html", context=context)
    elif request.method == 'POST':
        flash('Error: Adding spiders is not yet implemented. Try again later!', category='text-error')
        #context = helpers.get_spider_context(request)
        #queue.enqueue(spider.main, context)
        return redirect(url_for('frontpage'))
def entity_article_fexpenses(request, level, slug, id, format):
    c = get_context(request)
    entity = Entity.objects.get(level=level, slug=slug)
    return entities_show_policy(request, c, entity, id, '', _generator('gastosf-%s-%s-%s' % (level, slug, id), format, write_entity_functional_breakdown))
def frontpage():
    """
    Renders the front page.
    """
    context = helpers.get_context(request)
    return render_template("frontpage.html", context=context)
def entity_functional(request, level, slug, format):
    c = get_context(request)
    entity = Entity.objects.get(level=level, slug=slug, language=c['LANGUAGE_CODE'])
    return entities_show(request, c, entity, _generator('gastosf-%s-%s' % (level, slug), format, write_entity_functional_breakdown))
Exemple #9
0
def entities_expenses(request, level, format):
    return entities_index(
        request, get_context(request), level,
        _generator('gastos_%ss' % level, format,
                   write_entities_expenses_breakdown))
Exemple #10
0
def entities_income(request, level, format):
    return entities_index(
        request, get_context(request), level,
        _generator('ingresos_%ss' % level, format,
                   write_entities_income_breakdown))
Exemple #11
0
def entity_investment_line_breakdown(request, slug, id, format):
    c = get_context(request)
    return investments_show(
        request, id, '',
        _generator('inversiones-%s-%s' % (slug, id), format,
                   write_entity_investment_line_breakdown))
Exemple #12
0
def entity_payments(request, slug, format):
    c = get_context(request)
    c['payments'] = Payment.objects.all().prefetch_related('budget').order_by("-budget__year")
    return payment_search(request, _generator('pagos-%s' % (slug), format, write_entity_payment_breakdown))
Exemple #13
0
def entity_article_income(request, level, slug, id, format):
    c = get_context(request)
    entity = Entity.objects.get(level=level, slug=slug)
    return entities_show_article(request, c, entity, id, '', 'income', _generator('ingresos-%s-%s-%s' % (level, slug, id), format, write_economic_article_income_breakdown))
Exemple #14
0
def entity_investments_breakdown(request, slug, format):
    c = get_context(request)
    return investments(
        request,
        _generator('inversiones-%s' % (slug), format,
                   write_entity_investments_breakdown))
Exemple #15
0
def entity_article_expenses(request, level, slug, id, format):
    c = get_context(request)
    entity = Entity.objects.get(level=level, slug=slug, language=c['LANGUAGE_CODE'])
    return entities_show_article(request, c, entity, id, '', 'expense', _generator('ingresos-%s-%s-%s' % (level, slug, id), format, write_economic_article_expense_breakdown))
Exemple #16
0
def entity_income(request, level, slug, format):
    c = get_context(request)
    entity = Entity.objects.get(level=level, slug=slug)
    return entities_show(request, c, entity, _generator('ingresos-%s-%s' % (level, slug), format, write_entity_income_breakdown))
Exemple #17
0
def entity_expenses(request, level, slug, format):
    c = get_context(request)
    entity = Entity.objects.get(level=level, slug=slug)
    return entities_show(request, c, entity, _generator('gastos-%s-%s' % (level, slug), format, write_entity_economic_expense_breakdown))
Exemple #18
0
def entities_income(request, level, format):
    return entities_index(request, get_context(request), level, _generator('ingresos_%ss' % level, format, write_entities_income_breakdown))
Exemple #19
0
def entities_expenses(request, level, format):
    return entities_index(request, get_context(request), level, _generator('gastos_%ss' % level, format, write_entities_expenses_breakdown))