from django.db.transaction import non_atomic_requests
from django.utils.translation import (
    ugettext, ugettext_lazy as _, pgettext_lazy)

import jingo
import jinja2

from olympia import amo
from olympia.amo.helpers import urlparams
from olympia.amo.urlresolvers import reverse
from olympia.amo.utils import render


@jinja2.contextfunction
def install_button(context, addon, version=None, show_contrib=True,
                   show_warning=True, src='', collection=None, size='',
                   detailed=False, impala=False, latest_beta=False):
    """
    If version isn't given, we use the latest version. You can set latest_beta
    parameter to use latest beta version instead.
    """
    assert not (version and latest_beta), (
        'Only one of version and latest_beta can be specified')

    request = context['request']
    app, lang = context['APP'], context['LANG']