Exemple #1
0
def filter_values(request, param_name, param_value):

    try:
        disciplines = Dictionary.objects.get(name='discipline_slugs').content
    except ObjectDoesNotExist:
        disciplines = []
    if param_name in disciplines:
        raise Http404()

    try:
        param_value_is_int = isinstance(int(param_value), int)
    except ValueError:
        param_value_is_int = False

    # redirecting urls with integers as parameter's values where parameter is a foreign key
    if param_value_is_int:
        redirect = make_old_url_redirect(param_name, param_value)
        if redirect:
            return redirect

    if param_value_is_int or param_name == 'city_slug':
        filter_param = param_name
    else:
        filter_param = '{}__slug'.format(param_name)

    try:
        # colleges filtered by the initial filter
        colleges = College.objects.filter(**{
            filter_param: param_value
        }).order_by('name')
    except FieldError:
        raise Http404()

    try:
        # colleges filtered by secondary filters, request string for rendering links, readable values of applied filters and
        # dictionary of applied filters and their values
        colleges, req_str, noindex, filters_vals, params_dict = filter_by_params(
            request, colleges, '', '')
    except ValueError:
        raise Http404()

    # ids of favourite colleges
    favourite_colleges = []
    if 'favourite_colleges' in request.session:
        favourite_colleges = request.session['favourite_colleges']

    cookie_agreement = ''
    if 'cookie_agreement' in request.session:
        cookie_agreement = True

    if colleges.count() > 0:

        # parameter's text value and page link
        param_text_value, param_page_link = College.get_param_text_val(
            '', '', param_name, param_value)

        # define seo data before rendering
        seo_template = param_name
        seo_title = Seo.generate_title(seo_template, param_text_value, '')
        seo_description = Seo.generate_description(seo_template,
                                                   param_text_value, '')
        if not 'canonical' in locals():
            canonical = reverse('college_app:filter_values',
                                kwargs={
                                    'param_name': param_name,
                                    'param_value': param_value,
                                })

        # aggregate data
        aggregate_data = College.get_aggregate_data(colleges)

        # text with aggregate information for pages without get parameters
        aggregate_text = get_aggregate_filter_text_from_colleges(
            request, colleges)

        # check if result is multiple
        is_multiple = College.check_result_is_multiple(colleges)

        # sorting colleges
        colleges = College.sort(request, colleges)

        # sort parameters
        sort_params, active_sort_param_name = get_sort_params(request)

        # get filters
        filters = College.get_filters(colleges)

        # pagination
        colleges = create_paginator(request, colleges)

        # a url for pagination first page
        base_url = reverse('college_app:filter_values',
                           kwargs={
                               'param_name': param_name,
                               'param_value': param_value,
                           })
        # string for api call
        api_call = '{}={}&{}'.format(param_name, param_value, req_str)

        context = {
            'colleges': colleges,
            'is_multiple': is_multiple,
            'version': STATIC_VERSION,
            'aggregate_text': aggregate_text,
            # seo
            'seo_title': seo_title,
            'seo_description': seo_description,
            'canonical': canonical,
            'base_url': base_url,
            'noindex': noindex,
            # initial filter
            'init_filter_val': param_text_value,
            'init_param': param_name,
            'init_param_value': param_value,
            # other filters
            'filters_vals': filters_vals,
            'state_filter': True,
            # a string with parameters
            'params': req_str,
            # sort parameters
            'sort_params': sort_params,
            'active_sort_param_name': active_sort_param_name,
            # api
            'api_call': api_call,
            'gmaps_key': GOOGLE_MAPS_API,
            'ymaps_key': YANDEX_MAPS_API,
            'map_api_vendor': MAP_API_VENDOR,
            'favourite_colleges': favourite_colleges,
            'cookie_agreement': cookie_agreement,
        }
        context.update(filters)
        context.update(aggregate_data)

        return render(request, 'filtered_colleges.html', context)
    else:
        return render(
            request, 'filtered_colleges.html', {
                'error': True,
                'seo_title': 'Results',
                'noindex': True,
                'favourite_colleges': favourite_colleges,
                'cookie_agreement': cookie_agreement,
                'version': STATIC_VERSION,
            })
Exemple #2
0
def create_rating(request, rating_url):
    if not Rating.objects.filter(url=rating_url).exists():
        raise Http404()

    rating = Rating.objects.get(url=rating_url)
    rating_filters = rating.filters
    colleges = College.objects.all()
    # filtering colleges by rating's filters
    for f in rating_filters.all():
        if f.parameter_name:
            colleges = colleges.filter(**{f.parameter_name: f.parameter_value})

        if f.state:
            colleges = colleges.filter(state=f.state)

        if f.region:
            colleges = colleges.filter(region=f.region)

        if f.ownership:
            colleges = colleges.filter(ownership=f.ownership)

        if f.locale:
            colleges = colleges.filter(locale=f.locale)

        if f.degree:
            colleges = colleges.filter(degree=f.degree)

        if f.carnegie:
            colleges = colleges.filter(carnegie=f.carnegie)

        if f.religion:
            colleges = colleges.filter(religion=f.religion)

        if f.level:
            colleges = colleges.filter(level=f.level)

        if f.order:
            order_field_name = f.order
            if f.order.startswith('-'):
                order_field_name = f.order[1:]
            is_null_param = '{}__isnull'.format(order_field_name)
            colleges = colleges.filter(**{
                is_null_param: False
            }).order_by(f.order)

        if f.items_quantity:
            sliced_colleges_ids = [c.id for c in colleges[0:f.items_quantity]]
            colleges = colleges.filter(id__in=sliced_colleges_ids)

    # canonical page
    canonical = reverse('college_app:create_rating',
                        kwargs={'rating_url': rating_url})

    # a url for pagination first page
    base_url = reverse('college_app:create_rating',
                       kwargs={'rating_url': rating_url})

    # ids of favourite colleges
    favourite_colleges = []
    if 'favourite_colleges' in request.session:
        favourite_colleges = request.session['favourite_colleges']

    cookie_agreement = ''
    if 'cookie_agreement' in request.session:
        cookie_agreement = True

    # seo
    seo_title = rating.title
    seo_description = rating.description
    rating_header = rating.name

    params = request.GET
    # filtering colleges by filters applied on rating's page
    if len(params) > 0:
        # filtered colleges, request string for rendering links, readable values of applied filters and
        # dictionary of applied filters and their values
        try:
            colleges, req_str, noindex, filters_vals, params_dict = filter_by_params(
                request, colleges, '', '')
        except ValueError:
            raise Http404()

        if colleges.count() > 0:
            # aggregate data
            aggregate_data = College.get_aggregate_data(colleges)

            # sorting colleges
            colleges = College.sort(request, colleges)

            # sort parameters
            sort_params, active_sort_param_name = get_sort_params(request)

            # check if result is multiple
            is_multiple = College.check_result_is_multiple(colleges)

            # get filters
            filters = College.get_filters(colleges)

            # api
            api_call = College.create_api_call_string_from_ids(colleges)

            # pagination
            colleges = create_paginator(request, colleges)

            context = {
                'colleges': colleges,
                'is_multiple': is_multiple,
                'version': STATIC_VERSION,
                # seo
                'seo_title': seo_title,
                'seo_description': seo_description,
                'canonical': canonical,
                'base_url': base_url,
                'params': req_str,
                'noindex': noindex,
                'rating_header': rating_header,
                'rating_url': rating_url,
                # filters
                'filters_vals': filters_vals,
                # api
                'api_call': api_call,
                'gmaps_key': GOOGLE_MAPS_API,
                'ymaps_key': YANDEX_MAPS_API,
                'map_api_vendor': MAP_API_VENDOR,
                'favourite_colleges': favourite_colleges,
                'cookie_agreement': cookie_agreement,
                # sort parameters
                'sort_params': sort_params,
                'active_sort_param_name': active_sort_param_name,
            }
            context.update(filters)
            context.update(aggregate_data)

            return render(request, 'filtered_colleges.html', context)
        else:
            return render(
                request, 'filtered_colleges.html', {
                    'error': True,
                    'seo_title': 'Results',
                    'noindex': True,
                    'favourite_colleges': favourite_colleges,
                    'cookie_agreement': cookie_agreement,
                    'version': STATIC_VERSION,
                })
    else:
        # aggregate data
        aggregate_data = College.get_aggregate_data(colleges)

        # text with aggregate information for pages without get parameters
        aggregate_text = get_aggregate_filter_text_from_colleges(
            request, colleges)

        # api
        api_call = College.create_api_call_string_from_ids(colleges)

        # sort parameters
        sort_params, active_sort_param_name = get_sort_params(request)

        # check if result is multiple
        is_multiple = College.check_result_is_multiple(colleges)

        # get filters
        filters = College.get_filters(colleges)

        # pagination
        colleges = create_paginator(request, colleges)

        context = {
            'colleges': colleges,
            'is_multiple': is_multiple,
            'version': STATIC_VERSION,
            'aggregate_text': aggregate_text,
            # seo
            'seo_title': seo_title,
            'seo_description': seo_description,
            'rating_header': rating_header,
            'rating_url': rating_url,
            'canonical': canonical,
            'base_url': base_url,
            'noindex': False,
            # api
            'gmaps_key': GOOGLE_MAPS_API,
            'ymaps_key': YANDEX_MAPS_API,
            'map_api_vendor': MAP_API_VENDOR,
            'api_call': api_call,
            'favourite_colleges': favourite_colleges,
            'cookie_agreement': cookie_agreement,
            # sort parameters
            'sort_params': sort_params,
            'active_sort_param_name': active_sort_param_name,
        }
        context.update(filters)
        context.update(aggregate_data)

        return render(request, 'filtered_colleges.html', context)
Exemple #3
0
def main_filter(request):
    params = request.GET

    canonical = reverse('college_app:main_filter')

    # a url for pagination first page
    base_url = reverse('college_app:main_filter')

    # ids of favourite colleges
    favourite_colleges = []
    if 'favourite_colleges' in request.session:
        favourite_colleges = request.session['favourite_colleges']

    cookie_agreement = ''
    if 'cookie_agreement' in request.session:
        cookie_agreement = True

    if len(params) > 0:
        # filtered colleges, request string for rendering links, readable values of applied filters and
        # dictionary of applied filters and their values
        try:
            colleges, req_str, noindex, filters_vals, params_dict = filter_by_params(request, '', '', '', main_filter=True)
        except ValueError:
            raise Http404()

        if colleges.count() > 0:
            # aggregate data
            aggregate_data = College.get_aggregate_data(colleges)

            # sorting colleges
            colleges = College.sort(request, colleges)

            # sort parameters
            sort_params, active_sort_param_name = get_sort_params(request)

            # check if result is multiple
            is_multiple = College.check_result_is_multiple(colleges)

            # get filters
            filters = College.get_filters(colleges)

            # pagination
            colleges = create_paginator(request, colleges)

            context = {'colleges': colleges,
                       'is_multiple': is_multiple,
                       'version': STATIC_VERSION,
                       # seo
                       'seo_title': 'Results',
                       'canonical': canonical,
                       'base_url': base_url,
                       'params': req_str,
                       'noindex': noindex,
                       # filters
                       'filters_vals': filters_vals,
                       'main_filter': True,
                       'state_filter': True,
                       # api
                       'api_call': req_str + '&main_filter=1',
                       'gmaps_key': GOOGLE_MAPS_API,
                       'ymaps_key': YANDEX_MAPS_API,
                       'map_api_vendor': MAP_API_VENDOR,
                       'favourite_colleges': favourite_colleges,
                       'cookie_agreement': cookie_agreement,
                       # sort parameters
                       'sort_params': sort_params,
                       'active_sort_param_name': active_sort_param_name,
                       }
            context.update(filters)
            context.update(aggregate_data)

            return render(request, 'filtered_colleges.html', context)
        else:
            return render(request, 'filtered_colleges.html', {
                'error': True,
                'seo_title': 'Results',
                'noindex': True,
                'favourite_colleges': favourite_colleges,
                'cookie_agreement': cookie_agreement,
                'version': STATIC_VERSION,
            })
    else:
        colleges = College.objects.all()

        # aggregate data
        aggregate_data = College.get_aggregate_data(colleges)

        # sort parameters
        sort_params, active_sort_param_name = get_sort_params(request)

        # define seo data before rendering
        seo_title = Seo.generate_title('main', '', '')
        seo_description = Seo.generate_description('main', '', '')

        # check if result is multiple
        is_multiple = College.check_result_is_multiple(colleges)

        # get filters
        filters = College.get_filters(colleges)

        # pagination
        colleges = create_paginator(request, colleges)

        # text with aggregate information
        aggregate_text = generate_filter_text()

        context = {'colleges': colleges,
                   'is_multiple': is_multiple,
                   'version': STATIC_VERSION,
                   'aggregate_text': aggregate_text,
                   # seo
                   'seo_title': seo_title,
                   'seo_description': seo_description,
                   'canonical': canonical,
                   'base_url': base_url,
                   'noindex': False,
                   # api
                   'gmaps_key': GOOGLE_MAPS_API,
                   'ymaps_key': YANDEX_MAPS_API,
                   'map_api_vendor': MAP_API_VENDOR,
                   'api_call': 'main_filter=1',
                   'favourite_colleges': favourite_colleges,
                   'cookie_agreement': cookie_agreement,
                   # filter
                   'state_filter': True,
                   # sort parameters
                   'sort_params': sort_params,
                   'active_sort_param_name': active_sort_param_name,
                   }
        context.update(filters)
        context.update(aggregate_data)

        return render(request, 'filtered_colleges.html', context)
Exemple #4
0
def search(request):
    params = request.GET

    if len(params) == 0:
        return HttpResponsePermanentRedirect(reverse('college_app:index'))
    else:
        try:
            query = request.GET['text']
        except KeyError:
            raise Http404()
        # posgres solution
        # colleges = College.objects.annotate(search=SearchVector('name', 'city', 'state__name', 'region__name'),
        #                                     ).filter(search=query)
        colleges = College.objects.filter(Q(name__icontains=query) | Q(city__icontains=query) | Q(state__name__icontains=query) | Q(region__name__icontains=query))

        try:
            # colleges filtered by secondary filters, request string for rendering links, readable values of applied filters and
            # dictionary of applied filters and their values
            colleges, req_str, noindex, filters_vals, params_dict = filter_by_params(request, colleges, '', '')
        except ValueError:
            raise Http404()

        # ids of favourite colleges
        favourite_colleges = []
        if 'favourite_colleges' in request.session:
            favourite_colleges = request.session['favourite_colleges']

        cookie_agreement = ''
        if 'cookie_agreement' in request.session:
            cookie_agreement = True

        if colleges.count() > 0:

            canonical = reverse('college_app:search')

            # sorting colleges
            colleges = College.sort(request, colleges)

            # sort parameters
            sort_params, active_sort_param_name = get_sort_params(request)

            # aggregate data
            aggregate_data = College.get_aggregate_data(colleges)

            # check if result is multiple
            is_multiple = College.check_result_is_multiple(colleges)

            # get filters
            filters = College.get_filters(colleges)

            # pagination
            colleges = create_paginator(request, colleges)

            # a url for pagination first page
            base_url = reverse('college_app:search')

            # string for api call
            api_call = 'text={}&{}'.format(query, req_str)

            context = {'colleges': colleges,
                       'is_multiple': is_multiple,
                       'version': STATIC_VERSION,
                       # seo
                       'canonical': canonical,
                       'seo_title': 'Search',
                       'base_url': base_url,
                       'noindex': True,
                       # filters
                       'filters_vals': filters_vals,
                       'state_filter': True,
                       'serach_query': query,
                       # a string with parameters
                       'params': req_str,
                       # api
                       'api_call': api_call,
                       'gmaps_key': GOOGLE_MAPS_API,
                       'ymaps_key': YANDEX_MAPS_API,
                       'map_api_vendor': MAP_API_VENDOR,
                       'favourite_colleges': favourite_colleges,
                       # sort parameters
                       'sort_params': sort_params,
                       'active_sort_param_name': active_sort_param_name,
                       'cookie_agreement': cookie_agreement,
                       }

            context.update(aggregate_data)
            context.update(filters)

            return render(request, 'filtered_colleges.html', context)
        else:
            return render(request, 'filtered_colleges.html', {
                'error': True,
                'seo_title': 'Results',
                'noindex': True,
                'favourite_colleges': favourite_colleges,
                'cookie_agreement': cookie_agreement,
                'version': STATIC_VERSION,
            })
Exemple #5
0
def get_geo(request, geo_name, geo_slug):
    try:
        if geo_name == 'region':
            geo_obj = Region.objects.get(slug=geo_slug)
            region_name, slug, region_states = geo_obj.get_parsed_names()
            colleges = College.objects.filter(
                region=geo_obj.id).order_by('name')
            filters = College.get_filters(colleges)
            aggregate_text = generate_filter_text(geo_obj.id)
        else:
            geo_obj = State.objects.get(slug=geo_slug)
            colleges = College.objects.filter(
                state=geo_obj.id).order_by('name')
            filters = College.get_filters(colleges, excluded_filters=['state'])
            aggregate_text = generate_filter_text('', geo_obj.id)
    except ObjectDoesNotExist:
        raise Http404()

    # aggregate data
    aggregate_data = College.get_aggregate_data(colleges)

    # sorting colleges
    colleges = College.sort(request, colleges)

    # sort parameters
    sort_params, active_sort_param_name, active_sort_param_val = get_sort_params(
        request, is_geo_view=True)
    # sort param to insert into pagination url
    noindex = False
    if active_sort_param_val:
        active_sort_param_val = 'sort={}'.format(active_sort_param_val)
        noindex = True

    # define seo data before rendering
    seo_title = Seo.generate_title('geo_init', geo_obj.name, '')
    seo_description = Seo.generate_description('geo_init', geo_obj.name, '')

    # check if result is multiple
    is_multiple = College.check_result_is_multiple(colleges)

    # pagination
    colleges = create_paginator(request, colleges)

    # canonical link
    canonical = reverse('college_app:geo',
                        kwargs={
                            'geo_name': geo_name,
                            'geo_slug': geo_slug,
                        })

    # string for api call
    api_call = '{}={}'.format(geo_name, geo_obj.id)

    # ids of favourite colleges
    favourite_colleges = []
    if 'favourite_colleges' in request.session:
        favourite_colleges = request.session['favourite_colleges']

    cookie_agreement = ''
    if 'cookie_agreement' in request.session:
        cookie_agreement = True

    context = {
        'colleges': colleges,
        'is_multiple': is_multiple,
        'version': STATIC_VERSION,
        'aggregate_text': aggregate_text,
        # state data
        'slug': geo_slug,
        'view_name': 'college_app:geo_param',
        'geo_name': geo_name,
        # seo
        'seo_title': seo_title,
        'seo_description': seo_description,
        'base_url': canonical,
        'canonical': canonical,
        'noindex': noindex,
        # api
        'gmaps_key': GOOGLE_MAPS_API,
        'ymaps_key': YANDEX_MAPS_API,
        'map_api_vendor': MAP_API_VENDOR,
        'api_call': api_call,
        'favourite_colleges': favourite_colleges,
        # sort parameters
        'sort_params': sort_params,
        'active_sort_param_name': active_sort_param_name,
        'params': active_sort_param_val,
        'cookie_agreement': cookie_agreement,
    }

    if geo_name == 'region':
        context.update({
            # region data
            'region_name': region_name,
            'region_states': region_states,
            'region_id': geo_obj.id,
            'state_filter': True,
            'region_init': True,
        })
    else:
        context.update({
            # state data
            'state': geo_obj,
            'state_name': geo_obj.name,
            'state_init': True,
            'state_view': True,
        })

    context.update(filters)
    context.update(aggregate_data)

    return render(request, 'filtered_colleges.html', context)
Exemple #6
0
def get_geo_param(request, geo_name, geo_slug, param_name, param_value):
    """
    Takes filters, filter values, and colleges to show on filter page

    :param request:
    :param geo_name:
    :param geo_slug:
    :param param_name: name of filter's parameter
    :param param_value: value of filter's parameter
    :return:
    """

    try:
        if geo_name == 'region':
            geo_obj = Region.objects.get(slug=geo_slug)
        else:
            geo_obj = State.objects.get(slug=geo_slug)
    except ObjectDoesNotExist:
        raise Http404()

    try:
        param_value_is_int = isinstance(int(param_value), int)
    except ValueError:
        param_value_is_int = False

    # redirecting urls with integers as parameter's values where parameter is a foreign key
    if param_value_is_int:
        redirect = make_old_url_redirect(param_name, param_value, geo_slug,
                                         geo_name)
        if redirect:
            return redirect

    # modify parameter name if it is a discipline
    filter_param = modify_param(param_name, param_value, param_value_is_int)

    try:
        # colleges filtered by region/state + by the initial filter
        colleges = College.objects.filter(**{
            '{}__slug'.format(geo_name): geo_slug
        }).filter(**{
            filter_param: param_value
        }).order_by('name')
    except FieldError:
        raise Http404()

    # colleges filtered by secondary filters, request string for rendering links, readable values of applied filters and
    # dictionary of applied filters and their values
    try:
        colleges, req_str, noindex, filters_vals, params_dict = filter_by_params(
            request, colleges, geo_name, geo_obj.id)
    except ValueError:
        raise Http404()

    # ids of favourite colleges
    favourite_colleges = []
    if 'favourite_colleges' in request.session:
        favourite_colleges = request.session['favourite_colleges']

    cookie_agreement = ''
    if 'cookie_agreement' in request.session:
        cookie_agreement = True

    if colleges.count() > 0:
        if geo_name == 'region':
            seo_name, region_slug, region_states = geo_obj.get_parsed_names()
        else:
            seo_name = geo_obj.name

        # parameter's text value and page link
        param_text_value, param_page_link = College.get_param_text_val(
            geo_name, geo_obj.id, param_name, param_value)

        # sorting colleges
        colleges = College.sort(request, colleges)

        # sort parameters
        sort_params, active_sort_param_name = get_sort_params(request)

        # define seo data before rendering
        seo_template = param_name
        seo_title = Seo.generate_title(seo_template, param_text_value,
                                       seo_name)
        seo_description = Seo.generate_description(seo_template,
                                                   param_text_value, seo_name)
        # if parameter is a city, create canonical address pointing at the city view
        if param_name == 'city_slug':
            canonical = reverse('college_app:filter_values',
                                kwargs={
                                    'param_name': param_name,
                                    'param_value': slugify(param_value),
                                })
        # if parameter is a state, create canonical address pointing at the state view
        elif param_name == 'state':
            canonical = reverse('college_app:geo',
                                kwargs={
                                    'geo_name': param_name,
                                    'geo_slug': slugify(param_value),
                                })
        else:
            canonical = reverse('college_app:geo_param',
                                kwargs={
                                    'geo_name': geo_name,
                                    'geo_slug': geo_slug,
                                    'param_name': param_name,
                                    'param_value': slugify(param_value),
                                })
        # state's url
        geo_page = reverse('college_app:geo',
                           kwargs={
                               'geo_name': geo_name,
                               'geo_slug': geo_slug,
                           })

        # aggregate data
        aggregate_data = College.get_aggregate_data(colleges)

        # text with aggregate information for pages without get parameters
        aggregate_text = get_aggregate_filter_text_from_colleges(
            request, colleges)

        # check if result is multiple
        is_multiple = College.check_result_is_multiple(colleges)

        # get filters
        filters = College.get_filters(colleges)

        # pagination
        colleges = create_paginator(request, colleges)

        # string for an api call
        api_call = '{}={}&{}={}&{}'.format(geo_name, geo_obj.id, param_name,
                                           param_value, req_str)

        context = {
            'colleges': colleges,
            'is_multiple': is_multiple,
            'version': STATIC_VERSION,
            'aggregate_text': aggregate_text,
            # seo
            'seo_title': seo_title,
            'seo_description': seo_description,
            'noindex': noindex,
            'canonical': canonical,
            'base_url': canonical,
            # geo data
            '{}_id'.format(geo_name): geo_obj.id,
            'slug': geo_slug,
            'geo_page': geo_page,
            'view_name': 'college_app:geo_param',
            # initial filter
            'init_filter_val': param_text_value,
            'init_filter_page': param_page_link,
            # other filters
            'filters_vals': filters_vals,
            # sort parameters
            'sort_params': sort_params,
            'active_sort_param_name': active_sort_param_name,
            # a string with parameters
            'params': req_str,
            # api
            'api_call': api_call,
            'gmaps_key': GOOGLE_MAPS_API,
            'ymaps_key': YANDEX_MAPS_API,
            'map_api_vendor': MAP_API_VENDOR,
            'favourite_colleges': favourite_colleges,
            'cookie_agreement': cookie_agreement,
        }

        if geo_name == 'region':
            context.update({
                # region data
                'region_name': seo_name,
                'geo': seo_name,
                'state_filter': True,
            })
        else:
            context.update({
                # state data
                'state': geo_obj,
                'state_name': geo_obj.name,
                'state_view': True,
                'geo': geo_obj.name,
            })

        context.update(filters)
        context.update(aggregate_data)

        return render(request, 'filtered_colleges.html', context)

    else:
        return render(
            request, 'filtered_colleges.html', {
                'error': True,
                'seo_title': 'Results',
                'noindex': True,
                'favourite_colleges': favourite_colleges,
                'cookie_agreement': cookie_agreement,
                'version': STATIC_VERSION,
            })