diff --git a/hc/payments/tests/test_pricing.py b/hc/payments/tests/test_pricing.py index f53fe6b2..147a934c 100644 --- a/hc/payments/tests/test_pricing.py +++ b/hc/payments/tests/test_pricing.py @@ -35,3 +35,14 @@ class PricingTestCase(BaseTestCase): r = self.client.get("/pricing/") self.assertContains(r, "To manage this team") + + def test_it_shows_active_plan(self): + self.sub = Subscription(user=self.alice) + self.sub.subscription_id = "test-id" + self.sub.plan_id = "P5" + self.sub.save() + + self.client.login(username="alice@example.org", password="password") + + r = self.client.get("/pricing/") + self.assertContains(r, "Standard (monthly)", status_code=200) diff --git a/hc/payments/views.py b/hc/payments/views.py index 98eb7646..c5ed8c26 100644 --- a/hc/payments/views.py +++ b/hc/payments/views.py @@ -3,7 +3,6 @@ from django.contrib.auth.decorators import login_required from django.http import (HttpResponseBadRequest, HttpResponseForbidden, JsonResponse, HttpResponse) from django.shortcuts import get_object_or_404, redirect, render -from django.template.loader import render_to_string from django.views.decorators.csrf import csrf_exempt from django.views.decorators.http import require_POST import six @@ -24,7 +23,11 @@ def pricing(request): ctx = {"page": "pricing"} return render(request, "payments/pricing_not_owner.html", ctx) - ctx = {"page": "pricing"} + # Don't use Subscription.objects.for_user method here, so a + # subscription object is not created just by viewing a page. + sub = Subscription.objects.filter(user_id=request.user.id).first() + + ctx = {"page": "pricing", "sub": sub} return render(request, "payments/pricing.html", ctx) diff --git a/templates/accounts/billing.html b/templates/accounts/billing.html index cf33b984..382a7044 100644 --- a/templates/accounts/billing.html +++ b/templates/accounts/billing.html @@ -238,7 +238,7 @@ value="Y48" {% if sub.plan_id == "Y48" %} checked {% endif %}> - Yearly, $48/year (20% off monthly) + Annual, $48/year (20% off monthly)
Your account is currently on the {% if sub.plan_id == "P5" %} - Monthly Standard + Standard (monthly) {% elif sub.plan_id == "P50" %} - Monthly Plus + Plus (monthly) {% elif sub.plan_id == "Y48" %} - Yearly Standard + Standard (annual) {% elif sub.plan_id == "Y480" %} - Yearly Plus + Plus (annual) {% else %} Free {% endif %}