diff --git a/rowers/braintreestuff.py b/rowers/braintreestuff.py
index 145a766d..92a10f28 100644
--- a/rowers/braintreestuff.py
+++ b/rowers/braintreestuff.py
@@ -418,35 +418,72 @@ def create_subscription(rower, data):
return False, 0 # pragma: no cover
-
def cancel_subscription(rower, id):
themessages = []
errormessages = []
+
+ # 1. Fetch subscription first so we can read paid_through_date
try:
- _ = gateway.subscription.cancel(id)
- themessages.append("Subscription canceled")
- except: # pragma: no cover
+ subscription = gateway.subscription.find(id)
+ paid_through = subscription.paid_through_date # may be None
+ except Exception:
errormessages.append(
"We could not find the subscription record in our customer database."
- " We have notified the site owner, who will contact you.")
+ " We have notified the site owner, who will contact you."
+ )
- name = '{f} {l}'.format(f=rower.user.first_name,
- l=rower.user.last_name)
+ name = f"{rower.user.first_name} {rower.user.last_name}"
- _ = myqueue(queuehigh,
- handle_send_email_failed_cancel,
- name, rower.user.email, rower.user.username, id)
+ _ = myqueue(
+ queuehigh,
+ handle_send_email_failed_cancel,
+ name,
+ rower.user.email,
+ rower.user.username,
+ id,
+ )
return False, themessages, errormessages
+ # 2. Attempt cancellation
+ try:
+ _ = gateway.subscription.cancel(id)
+ themessages.append("Subscription canceled")
+ except Exception: # pragma: no cover
+ errormessages.append(
+ "We could not find the subscription record in our customer database."
+ " We have notified the site owner, who will contact you."
+ )
+
+ name = f"{rower.user.first_name} {rower.user.last_name}"
+
+ _ = myqueue(
+ queuehigh,
+ handle_send_email_failed_cancel,
+ name,
+ rower.user.email,
+ rower.user.username,
+ id,
+ )
+
+ return False, themessages, errormessages
+
+ # 3. Update rower object (using paid_through_date)
basicplans = PaidPlan.objects.filter(price=0, paymentprocessor='braintree')
rower.paidplan = basicplans[0]
+
+ # teamplanexpires stays "now" (as you had it)
rower.teamplanexpires = timezone.now()
- rower.planexpires = timezone.now()
+
+ # planexpires becomes the user's real, fully paid end date
+ # fallback = now() if Braintree somehow returns None
+ rower.planexpires = paid_through or timezone.now()
+
rower.clubsize = 0
rower.rowerplan = 'basic'
rower.subscription_id = None
rower.save()
+
themessages.append("Your plan was reset to basic")
return True, themessages, errormessages
diff --git a/rowers/templates/frontpage.html b/rowers/templates/frontpage.html
index 7b10cdc4..0b12898e 100644
--- a/rowers/templates/frontpage.html
+++ b/rowers/templates/frontpage.html
@@ -44,14 +44,7 @@
{% if user.is_anonymous %}
-
-
-
-
SIGN UP FREE
-
-
-
-
+
diff --git a/rowers/templates/landingpage.html b/rowers/templates/landingpage.html
index cb68078a..23d9b9ba 100644
--- a/rowers/templates/landingpage.html
+++ b/rowers/templates/landingpage.html
@@ -209,13 +209,6 @@
- {% if not user.is_authenticated %}
-
- {% endif %}
@@ -353,9 +346,6 @@ using my NK empower oarlock for about a month now, and I‘m really
Contact
-
- Paid Plans
-
Legal
diff --git a/rowers/urls.py b/rowers/urls.py
index b2942bf8..934c9fe7 100644
--- a/rowers/urls.py
+++ b/rowers/urls.py
@@ -832,7 +832,6 @@ urlpatterns = [
name='payment_completed_view'),
re_path(r'^downgradecompleted/$', views.downgrade_completed_view,
name='downgrade_completed_view'),
- re_path(r'^paidplans/$', views.paidplans_view, name='paidplans_view'),
re_path(r'^me/cancelsubscriptions/$',
views.plan_stop_view, name='plan_stop_view'),
re_path(r'^me/cancelsubscription/(?P
[\w\ ]+.*)/$',
@@ -847,10 +846,6 @@ urlpatterns = [
re_path(r'^starttrial/$', views.start_trial_view, name='start_trial_view'),
re_path(r'^legal', TemplateView.as_view(
template_name='legal.html'), name='legal'),
- re_path(r'^register/$', views.rower_register_view,
- name='rower_register_view'),
- re_path(r'^coachregister/$', views.coach_register_view,
- name='coach_register_view'),
path('activate///', views.useractivate, name='useractivate'),
re_path(r'^register/thankyou/$', TemplateView.as_view(
template_name='registerthankyou.html'), name='registerthankyou'),
diff --git a/templates/newbase.html b/templates/newbase.html
index 4c606e18..788ebb9b 100644
--- a/templates/newbase.html
+++ b/templates/newbase.html
@@ -165,11 +165,6 @@
{% else %}
-
-
-
-
-
@@ -230,7 +225,7 @@
{% if user.rower.planexpires|date_dif|ddays < 4 %}
- You have {{ user.rower.planexpires|date_dif|ddays }} days left of your one year subscription. Please renew on or before {{ user.rower.planexpires }} or your plan will be reset to Basic. Click here to renew your membership.
+ You have {{ user.rower.planexpires|date_dif|ddays }} days left of your one year subscription. Please renew on or before {{ user.rower.planexpires }} or your plan will be reset to Basic.
{% endif %}
{% endif %}
@@ -239,14 +234,14 @@
{% if user.rower.plantrialexpires and user.rower.plantrialexpires|is_future_date and user.rower.rowerplan != 'plan' %}
- {{ user.rower.protrialexpires|date_dif|ddays }} days left of your Self-Coach trial - Would you like to upgrade now?
+ {{ user.rower.protrialexpires|date_dif|ddays }} days left of your Self-Coach trial
{% else %}
{% if user.rower.rowerplan == 'basic' %}
- {{ user.rower.protrialexpires|date_dif|ddays }} days left of your Pro trial - Would you like to upgrade now?
+ {{ user.rower.protrialexpires|date_dif|ddays }} days left of your Pro trial
{% endif %}
@@ -255,7 +250,7 @@
{% if user.rower.coachtrialexpires and user.rower.coachtrialexpires|is_future_date and user.rower.rowerplan != 'coach' %}
- {{ user.rower.coachtrialexpires|date_dif|ddays }} days left of your Coach trial - Would you like to upgrade now?
+ {{ user.rower.coachtrialexpires|date_dif|ddays }} days left of your Coach trial
{% endif %}
@@ -336,13 +331,7 @@
- {% if user.is_authenticated and user.rower.rowerplan == 'basic' %}
-
- {% elif user.is_authenticated and user.rower.rowerplan == 'pro' %}
+ {% if user.is_authenticated and user.rower.rowerplan == 'pro' %}