From 764a6a48f8f49a506f433dad538775aa57b1546c Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Thu, 21 Jul 2022 13:48:44 +0100 Subject: [PATCH] Fix error for unauthenticated user plan checks --- core/templatetags/has_plan.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/templatetags/has_plan.py b/core/templatetags/has_plan.py index 411327c..94a568f 100644 --- a/core/templatetags/has_plan.py +++ b/core/templatetags/has_plan.py @@ -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 \ No newline at end of file + return plan_name in plan_list