Fix error for unauthenticated user plan checks

This commit is contained in:
Mark Veidemanis 2022-07-21 13:48:44 +01:00
parent 11b5eb50ec
commit 764a6a48f8
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 5 additions and 2 deletions

View File

@ -1,8 +1,11 @@
from django import template
from core.models import User
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