def get_splits_report(request, planid):
    """
    Get the rendered splits report
    """
    note_session_activity(request)

    try:
        plan = Plan.objects.get(pk=planid)
    except:
        return HttpResponse(_('Plan does not exist.'), mimetype='text/plain')

    if not using_unique_session(request.user) or not can_view(request.user, plan):
        return HttpResponseForbidden()

    version = int(request.REQUEST['version'] if 'version' in request.REQUEST else plan.version)
    inverse = request.REQUEST['inverse'] == 'true' if 'inverse' in request.REQUEST else False
    extended = request.REQUEST['extended'] == 'true' if request.REQUEST in 'extended' else False
    layers = request.REQUEST.getlist('layers[]')
    if len(layers) == 0:
        return HttpResponse(_('No layers were provided.'), mimetype='text/plain')

    try :
        report = loader.get_template('split_report.html')
        html = ''
        for layer in layers:
            my_context = {'extended': extended}
            my_context.update(plan.compute_splits(layer, version = version, inverse = inverse, extended = extended))
            last_item = layer is layers[-1]
            community_info = plan.get_community_type_info(layer, version = version, inverse = inverse, include_counts=last_item)
            if community_info is not None:
                my_context.update(community_info)
            calc_context = DjangoContext(my_context)
            html += report.render(calc_context)
            if not last_item:
                html += '<hr />'
        return HttpResponse(html, mimetype='text/html')
    except Exception, ex:
        logger.warn('Could not produce split report')
        logger.debug('Reason: %s', ex)
        return HttpResponse(str(ex), mimetype='text/plain')
dataset/ETHPy150Open PublicMapping/DistrictBuilder/django/publicmapping/redistricting/views.py/get_splits_report/swapped operands of `in`