from django import template

register = template.Library()


@register.filter
def has_plan(user, plan_name):
    if not hasattr(user, "plans"):
        return False
    plan_list = [plan.name for plan in user.plans.all()]
    return plan_name in plan_list
