Browse Source

Fix active plan display in the pricing page.

pull/149/head
Pēteris Caune 7 years ago
parent
commit
1497ff204b
4 changed files with 22 additions and 8 deletions
  1. +11
    -0
      hc/payments/tests/test_pricing.py
  2. +5
    -2
      hc/payments/views.py
  3. +2
    -2
      templates/accounts/billing.html
  4. +4
    -4
      templates/payments/pricing.html

+ 11
- 0
hc/payments/tests/test_pricing.py View File

@ -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="[email protected]", password="password")
r = self.client.get("/pricing/")
self.assertContains(r, "Standard (monthly)", status_code=200)

+ 5
- 2
hc/payments/views.py View File

@ -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)


+ 2
- 2
templates/accounts/billing.html View File

@ -238,7 +238,7 @@
value="Y48"
{% if sub.plan_id == "Y48" %} checked {% endif %}>
<span class="radiomark"></span>
Yearly, $48/year (20% off monthly)
Annual, $48/year (20% off monthly)
</label>
<h2>Plus <small>Unlimited checks, unlimited team members</small></h2>
@ -259,7 +259,7 @@
value="Y480"
{% if sub.plan_id == "Y480" %} checked {% endif %}>
<span class="radiomark"></span>
Yearly, $480/year (20% off monthly)
Annual, $480/year (20% off monthly)
</label>
<div class="alert alert-warning">


+ 4
- 4
templates/payments/pricing.html View File

@ -15,13 +15,13 @@
<p>
Your account is currently on the
{% if sub.plan_id == "P5" %}
<strong>Monthly Standard</strong>
<strong>Standard (monthly)</strong>
{% elif sub.plan_id == "P50" %}
<strong>Monthly Plus</strong>
<strong>Plus (monthly)</strong>
{% elif sub.plan_id == "Y48" %}
<strong>Yearly Standard</strong>
<strong>Standard (annual)</strong>
{% elif sub.plan_id == "Y480" %}
<strong>Yearly Plus</strong>
<strong>Plus (annual)</strong>
{% else %}
<strong>Free</strong>
{% endif %}


Loading…
Cancel
Save