from django import template

from license_info.tools import check_features as cf
from license_info.tools import get_license_info

register = template.Library()


@register.simple_tag
def check_features(features):
    return cf(features)


@register.simple_tag
def has_license():
    """Check if license activated

    Usage:
    {% load license_info %}
    {% has_license as license %}

    and than
    {% if license %}
    <h1>We have an license</h1>
    {% endif %}
    """
    try:
        return get_license_info() is not None
    except:
        return False
