Fix error for unauthenticated user plan checks
This commit is contained in:
parent
11b5eb50ec
commit
764a6a48f8
|
@ -1,8 +1,11 @@
|
||||||
from django import template
|
from django import template
|
||||||
from core.models import User
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
||||||
|
|
||||||
@register.filter
|
@register.filter
|
||||||
def has_plan(user, plan_name):
|
def has_plan(user, plan_name):
|
||||||
|
if not hasattr(user, "plans"):
|
||||||
|
return False
|
||||||
plan_list = [plan.name for plan in user.plans.all()]
|
plan_list = [plan.name for plan in user.plans.all()]
|
||||||
return plan_name in plan_list
|
return plan_name in plan_list
|
Loading…
Reference in New Issue