from django import template

from .. import utils

register = template.Library()


@register.inclusion_tag("accounts/tags/renewal_table.html")
def renewal_table(user):
    if not user:
        return {}

    renewals = utils.get_renewals_by_user(user)

    return {"renewals": renewals}


@register.inclusion_tag("accounts/tags/subscription_table.html")
def subscription_table(user):
    if not user:
        return {}

    subscriptions = utils.get_subscriptions_by_user(user)

    return {"subscriptions": subscriptions}


@register.inclusion_tag("accounts/tags/order_table.html")
def order_table(user):
    if not user:
        return {}

    return {"orders": user.order_set.all()}
