# Path: blockexplorer/settings.py
# BLOCKCYPHER_API_KEY = os.getenv('BLOCKCYPHER_API_KEY')


from django.http import HttpResponseRedirect
from django.urls import reverse
from django.contrib import messages
from django.utils.translation import ugettext_lazy as _
from annoying.decorators import render_to
from blockexplorer.decorators import assert_valid_coin_symbol
from blockexplorer.settings import BLOCKCYPHER_API_KEY
from blockcypher.api import get_block_details, get_latest_block_height, get_block_overview, get_block_hash
from blockcypher.constants import COIN_SYMBOL_MAPPINGS
from blockcypher.utils import is_valid_hash
from utils import get_max_pages
                }),
            })
        messages.info(request, msg, extra_tags='safe')

        kwargs = {
                'coin_symbol': coin_symbol,
                'tx_hash': tx_hash,
                }

        redir_uri = reverse('transaction_overview', kwargs=kwargs) + '#advanced-details'

        return HttpResponseRedirect(redir_uri)

    else:
        msg = _('Sorry, block <strong>%(block_num)s</strong> only has <strong>%(n_tx)s</strong> transactions' % {
            'block_num': block_num,
            'n_tx': block_overview['n_tx'],
            })
        messages.warning(request, msg, extra_tags='safe')

        kwargs = {
                'coin_symbol': coin_symbol,
                'block_representation': block_num,
                }
        return HttpResponseRedirect(reverse('block_overview', kwargs=kwargs))


@assert_valid_coin_symbol
def latest_block(request, coin_symbol):
    latest_block_height = get_latest_block_height(coin_symbol=coin_symbol,

# Path: blockexplorer/settings.py
# BLOCKCYPHER_API_KEY = os.getenv('BLOCKCYPHER_API_KEY')


# Path: blocks/views.py
from django.http import HttpResponseRedirect
from django.urls import reverse
from django.contrib import messages
from django.utils.translation import ugettext_lazy as _
from annoying.decorators import render_to
from blockexplorer.decorators import assert_valid_coin_symbol
from blockexplorer.settings import BLOCKCYPHER_API_KEY
from blockcypher.api import get_block_details, get_latest_block_height, get_block_overview, get_block_hash
from blockcypher.constants import COIN_SYMBOL_MAPPINGS
from blockcypher.utils import is_valid_hash
from utils import get_max_pages

                }),
            })
        messages.info(request, msg, extra_tags='safe')

        kwargs = {
                'coin_symbol': coin_symbol,
                'tx_hash': tx_hash,
                }

        redir_uri = reverse('transaction_overview', kwargs=kwargs) + '#advanced-details'

        return HttpResponseRedirect(redir_uri)

    else:
        msg = _('Sorry, block <strong>%(block_num)s</strong> only has <strong>%(n_tx)s</strong> transactions' % {
            'block_num': block_num,
            'n_tx': block_overview['n_tx'],
            })
        messages.warning(request, msg, extra_tags='safe')

        kwargs = {
                'coin_symbol': coin_symbol,
                'block_representation': block_num,
                }
        return HttpResponseRedirect(reverse('block_overview', kwargs=kwargs))


@assert_valid_coin_symbol
def latest_block(request, coin_symbol):
    latest_block_height = get_latest_block_height(coin_symbol=coin_symbol,

            api_key=BLOCKCYPHER_API_KEY)