@unique_session_or_json_redirect
def getdistrictfile(request, planid):
    """
    Given a plan id, email the user a zipped copy of 
    the district index file
    """
    note_session_activity(request)

    # Get the districtindexfile and create a response
    plan = Plan.objects.get(pk=planid)
    if not can_copy(request.user, plan):
        return HttpResponseForbidden()
    
    is_shape = 'type' in request.REQUEST and request.REQUEST['type'] == 'shape'
    file_status = DistrictFile.get_file_status(plan, shape=is_shape)
    if file_status == 'done':
        if is_shape:
            archive = DistrictShapeFile.plan2shape(plan)
        else:
            archive = DistrictIndexFile.plan2index(plan)
        response = HttpResponse(open(archive.name).read(), content_type='application/zip')
        response['Content-Disposition'] = plan.get_friendly_name() % 'attachment; filename="%s.zip"'
    else:
        # Put in a celery task to create this file
        if is_shape:
            DistrictShapeFile.plan2shape.delay(plan)
        else:
            DistrictIndexFile.plan2index.delay(plan)
        response = HttpResponse(_('File is not yet ready. Please try again in '
            'a few minutes'))
    return response
dataset/ETHPy150Open PublicMapping/DistrictBuilder/django/publicmapping/redistricting/views.py/getdistrictfile/swapped operands of `%`