Ejemplo n.º 1
0
def search_suggestions(request):
    from digipal.utils import get_json_response
    from content_type.search_content_type import SearchContentType
    query = request.GET.get('q', '')
    try:
        limit = int(request.GET.get('l'))
    except:
        limit = 8
    suggestions = SearchContentType().get_suggestions(query, limit)
    return get_json_response(suggestions)
Ejemplo n.º 2
0
def search_suggestions(request):
    from digipal.utils import get_json_response
    from content_type.search_content_type import SearchContentType
    query = request.GET.get('q', '')
    try:
        limit = int(request.GET.get('l'))
    except:
        limit = 8
    suggestions = SearchContentType().get_suggestions(query, limit)
    return get_json_response(suggestions)
Ejemplo n.º 3
0
def patterns_api_view(request, root, path):
    ana = PatternAnalyser()
    data = ana.process_request_api(request, root, path)
    format = data.get('format', 'json')
    if format in ['csv']:
        now = datetime.now()
        file_name = 'segments-%s-%s-%s.csv' % (now.day, now.month, now.year)
        ret = dputils.get_csv_response_from_rows(data['csv'], headings=['unitid', 'pattern_group', 'pattern_key', 'segment', 'variant'], filename=file_name)
    else:
        ret = dputils.get_json_response(data)
    return ret
Ejemplo n.º 4
0
def patterns_api_view(request, root, path):
    ana = PatternAnalyser()
    data = ana.process_request_api(request, root, path)
    format = data.get('format', 'json')
    if format in ['csv']:
        now = datetime.now()
        file_name = 'segments-%s-%s-%s.csv' % (now.day, now.month, now.year)
        ret = dputils.get_csv_response_from_rows(data['csv'],
                                                 headings=[
                                                     'unitid', 'pattern_group',
                                                     'pattern_key', 'segment',
                                                     'variant'
                                                 ],
                                                 filename=file_name)
    else:
        ret = dputils.get_json_response(data)
    return ret