def campaign(request):
    '\n    View for the campaign service page.\n    '

    class NoRebuildAuthSession(requests.Session):

        def rebuild_auth(self, prepared_request, response):
            '\n            No code here means requests will always preserve the Authorization\n            header when redirected.\n            Be careful not to leak your credentials to untrusted hosts!\n            '
    url = 'https://api.givebutter.com/v1/transactions/'
    headers = {'Authorization': f'Bearer {settings.GIVEBUTTER_API_KEY}'}
    response = None
    session = NoRebuildAuthSession()
    try:
        r = session.get(url, headers=headers, timeout=0.75)
        if (r.status_code == 200):
            response = r.json()
        else:
            logger.error(f'ERROR in request: {r.status_code}')
    except requests.exceptions.Timeout:
        logger.warning('Connection to GiveButter API Timed out')
    except requests.ConnectionError:
        logger.warning('Connection to GiveButter API could not be resolved')
    except requests.exceptions.RequestException:
        logger.error('An unknown issue occurred while trying to retrieve GiveButter Donor List')
    ctx = _get_context('Campaign')
    if (response and ('data' in response)):
        response = response['data']
        logger.debug(f'GiveButter API Response: {response}')
        successful_txs = [tx for tx in response if (tx['status'] == 'succeeded')]
        sorted_txs = sorted(successful_txs, key=(lambda tx: tx['amount']), reverse=True)
        transactions = [{'name': tx['giving_space']['name'], 'amount': tx['giving_space']['amount'], 'message': tx['giving_space']['message']} for tx in sorted_txs[:20]]
        ctx['transactions'] = transactions
        ctx['num_txs'] = len(successful_txs)
    return render(request, 'public/campaign.html', ctx)
View for the campaign service page.
def campaign(request):
    '\n    \n    '

    class NoRebuildAuthSession(requests.Session):

        def rebuild_auth(self, prepared_request, response):
            '\n            No code here means requests will always preserve the Authorization\n            header when redirected.\n            Be careful not to leak your credentials to untrusted hosts!\n            '
    url = 'https://api.givebutter.com/v1/transactions/'
    headers = {'Authorization': f'Bearer {settings.GIVEBUTTER_API_KEY}'}
    response = None
    session = NoRebuildAuthSession()
    try:
        r = session.get(url, headers=headers, timeout=0.75)
        if (r.status_code == 200):
            response = r.json()
        else:
            logger.error(f'ERROR in request: {r.status_code}')
    except requests.exceptions.Timeout:
        logger.warning('Connection to GiveButter API Timed out')
    except requests.ConnectionError:
        logger.warning('Connection to GiveButter API could not be resolved')
    except requests.exceptions.RequestException:
        logger.error('An unknown issue occurred while trying to retrieve GiveButter Donor List')
    ctx = _get_context('Campaign')
    if (response and ('data' in response)):
        response = response['data']
        logger.debug(f'GiveButter API Response: {response}')
        successful_txs = [tx for tx in response if (tx['status'] == 'succeeded')]
        sorted_txs = sorted(successful_txs, key=(lambda tx: tx['amount']), reverse=True)
        transactions = [{'name': tx['giving_space']['name'], 'amount': tx['giving_space']['amount'], 'message': tx['giving_space']['message']} for tx in sorted_txs[:20]]
        ctx['transactions'] = transactions
        ctx['num_txs'] = len(successful_txs)
    return render(request, 'public/campaign.html', ctx)