def events_autocomplete(location_slug):
    location = deslugify(location_slug)
    results = get_object_list(Event, __event_search_location=location)
    results = marshal(results, EVENT)
    return jsonify([{
        'value': result['name'],
        'type': 'event_name'
    } for result in results])
def explore_view(location):
    placeholder_images = DataGetter.get_event_default_images()
    custom_placeholder = DataGetter.get_custom_placeholders()
    location = deslugify(location)
    query = request.args.get('query', '')

    filtering = {'privacy': 'public', 'state': 'Published'}
    start, end = None, None
    word = request.args.get('query', None)
    event_type = request.args.get('type', None)
    day_filter = request.args.get('period', None)
    sub_category = request.args.get('sub-category', None)
    category = request.args.get('category', None)

    if day_filter:
        start, end = get_date_range(day_filter)
    if location and location != 'world':
        filtering['__event_search_location'] = location
    if word:
        filtering['__event_contains'] = word
    if category:
        filtering['topic'] = category
    if sub_category:
        filtering['sub_topic'] = sub_category
    if event_type:
        filtering['type'] = event_type
    if start:
        filtering['__event_start_time_gt'] = start
    if end:
        filtering['__event_end_time_lt'] = end

    results = marshal(get_paginated(**filtering), EVENT_PAGINATED)
    filters = clean_dict(request.args.items())

    custom_placeholder_serializable = {}
    for custom_placeholder_item in custom_placeholder:
        custom_placeholder_serializable[
            custom_placeholder_item.name] = custom_placeholder_item.thumbnail

    return render_template(
        'gentelella/guest/explore/results.html',
        results=json.dumps(results['results']),
        location=location if location != 'world' else '',
        position=json.dumps(get_coordinates(location)),
        count=results['count'],
        query_args=json.dumps(filters),
        placeholder_images=json.dumps(placeholder_images),
        custom_placeholder=json.dumps(custom_placeholder_serializable),
        categories=EVENT_TOPICS,
        results_per_page=RESULTS_PER_PAGE,
        query=query)
Esempio n. 3
0
def explore_view(location):
    placeholder_images = DataGetter.get_event_default_images()
    custom_placeholder = DataGetter.get_custom_placeholders()
    location = deslugify(location)
    query = request.args.get('query', '')

    filtering = {'privacy': 'public', 'state': 'Published'}
    start, end = None, None
    word = request.args.get('query', None)
    event_type = request.args.get('type', None)
    day_filter = request.args.get('period', None)
    sub_category = request.args.get('sub-category', None)
    category = request.args.get('category', None)

    if day_filter:
        start, end = get_date_range(day_filter)
    if location and location != 'world':
        filtering['__event_search_location'] = location
    if word:
        filtering['__event_contains'] = word
    if category:
        filtering['topic'] = category
    if sub_category:
        filtering['sub_topic'] = sub_category
    if event_type:
        filtering['type'] = event_type
    if start:
        filtering['__event_start_time_gt'] = start
    if end:
        filtering['__event_end_time_lt'] = end

    results = marshal(get_paginated(**filtering), EVENT_PAGINATED)
    filters = clean_dict(request.args.items())

    custom_placeholder_serializable = {}
    for custom_placeholder_item in custom_placeholder:
        custom_placeholder_serializable[custom_placeholder_item.name] = custom_placeholder_item.thumbnail

    return render_template('gentelella/guest/explore/results.html',
                           results=json.dumps(results['results']),
                           location=location if location != 'world' else '',
                           position=json.dumps(get_coordinates(location)),
                           count=results['count'],
                           query_args=json.dumps(filters),
                           placeholder_images=json.dumps(placeholder_images),
                           custom_placeholder=json.dumps(custom_placeholder_serializable),
                           categories=EVENT_TOPICS,
                           results_per_page=RESULTS_PER_PAGE,
                           query=query)
    def explore_view(self, location):
        placeholder_images = DataGetter.get_event_default_images()
        custom_placeholder = DataGetter.get_custom_placeholders()
        location = deslugify(location)
        current_page = request.args.get('page')
        query = request.args.get('query', '')
        if not current_page:
            current_page = 1
        else:
            current_page = int(current_page)

        filtering = {'privacy': 'public', 'state': 'Published'}
        start, end = None, None
        word = request.args.get('query', None)
        event_type = request.args.get('type', None)
        day_filter = request.args.get('period', None)
        sub_category = request.args.get('sub-category', None)
        category = request.args.get('category', None)
        print location
        if day_filter:
            start, end = get_date_range(day_filter)
        if location:
            filtering['__event_search_location'] = location
        if word:
            filtering['__event_contains'] = word
        if category:
            filtering['topic'] = category
        if sub_category:
            filtering['sub_topic'] = sub_category
        if event_type:
            filtering['type'] = event_type
        if start:
            filtering['__event_start_time_gt'] = start
        if end:
            filtering['__event_end_time_lt'] = end
        filters = request.args.items()
        erase_from_dict(filters, 'page')
        results = get_paginated(**filtering)

        return self.render('/gentelella/guest/search/results.html',
                           results=results,
                           location=location,
                           filters=filters,
                           current_page=current_page,
                           placeholder_images=placeholder_images,
                           custom_placeholder=custom_placeholder,
                           categories=CATEGORIES,
                           query=query)
    def explore_view(self, location):
        placeholder_images = DataGetter.get_event_default_images()
        custom_placeholder = DataGetter.get_custom_placeholders()
        location = deslugify(location)
        current_page = request.args.get('page')
        query = request.args.get('query', '')
        if not current_page:
            current_page = 1
        else:
            current_page = int(current_page)

        filtering = {'privacy': 'public', 'state': 'Published'}
        start, end = None, None
        word = request.args.get('query', None)
        event_type = request.args.get('type', None)
        day_filter = request.args.get('period', None)
        sub_category = request.args.get('sub-category', None)
        category = request.args.get('category', None)
        print location
        if day_filter:
            start, end = get_date_range(day_filter)
        if location:
            filtering['__event_search_location'] = location
        if word:
            filtering['__event_contains'] = word
        if category:
            filtering['topic'] = category
        if sub_category:
            filtering['sub_topic'] = sub_category
        if event_type:
            filtering['type'] = event_type
        if start:
            filtering['__event_start_time_gt'] = start
        if end:
            filtering['__event_end_time_lt'] = end
        filters = request.args.items()
        erase_from_dict(filters, 'page')
        results = get_paginated(**filtering)

        return self.render('/gentelella/guest/search/results.html',
                           results=results,
                           location=location,
                           filters=filters,
                           current_page=current_page,
                           placeholder_images=placeholder_images,
                           custom_placeholder=custom_placeholder,
                           categories=CATEGORIES, query=query)
Esempio n. 6
0
 def events_autocomplete(self, location_slug):
     location = deslugify(location_slug)
     results = get_object_list(Event, __event_search_location=location)
     results = marshal(results, EVENT)
     return jsonify([{'value': result['name'], 'type': 'event_name'} for result in results])