From 0859efb0adce9348d4b71f4af7c4fe33b0f161fe Mon Sep 17 00:00:00 2001 From: nospame Date: Tue, 27 Aug 2024 14:08:49 -0700 Subject: [PATCH] Add can_change_subscription check to SelectPlanView --- corehq/apps/domain/views/accounting.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/corehq/apps/domain/views/accounting.py b/corehq/apps/domain/views/accounting.py index 273db2231767..96716f23cff4 100644 --- a/corehq/apps/domain/views/accounting.py +++ b/corehq/apps/domain/views/accounting.py @@ -971,6 +971,17 @@ class SelectPlanView(DomainAccountingSettings): edition = None lead_text = gettext_lazy("Please select a plan below that fits your organization's needs.") + def dispatch(self, request, *args, **kwargs): + if not self.can_change_subscription: + raise Http404() + return super().dispatch(request, *args, **kwargs) + + @property + def can_change_subscription(self): + subscription = self.current_subscription + is_annual_plan = subscription.plan_version.plan.is_annual_plan + return not is_annual_plan + @property @memoized def can_domain_unpause(self):