mirror of
https://github.com/simple-login/app.git
synced 2024-09-27 20:31:30 +02:00
replace user.next_bill_date() by sub.next_bill_date.strftime("%Y-%m-%d")
This commit is contained in:
parent
b0118e615a
commit
f7f1e7f358
@ -14,7 +14,7 @@
|
||||
{% if sub.cancelled %}
|
||||
<p>
|
||||
You are on the <b>{{ sub.plan_name() }}</b> plan. <br>
|
||||
You have canceled your subscription and it will end on {{ current_user.next_bill_date() }}
|
||||
You have canceled your subscription and it will end on {{ sub.next_bill_date.strftime("%Y-%m-%d") }}
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
@ -57,9 +57,10 @@
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{% if current_user.is_cancel() %}
|
||||
{% set sub = current_user.get_subscription() %}
|
||||
{% if sub and sub.cancelled %}
|
||||
<div class="alert alert-primary" role="alert">
|
||||
You have an active subscription until {{current_user.next_bill_date()}}. <br>
|
||||
You have an active subscription until {{ sub.next_bill_date.strftime("%Y-%m-%d") }}. <br>
|
||||
Please note that if you re-subscribe now, this will be a completely
|
||||
new subscription and
|
||||
your payment method will be charged <b>immediately</b>.
|
||||
|
@ -262,16 +262,6 @@ class User(db.Model, ModelMixin, UserMixin):
|
||||
|
||||
return True
|
||||
|
||||
def next_bill_date(self) -> str:
|
||||
sub: Subscription = self.get_subscription()
|
||||
if sub:
|
||||
return sub.next_bill_date.strftime("%Y-%m-%d")
|
||||
|
||||
LOG.error(
|
||||
f"next_bill_date() should be called only on user with active subscription. User {self}"
|
||||
)
|
||||
return ""
|
||||
|
||||
def is_cancel(self) -> bool:
|
||||
"""User has canceled their subscription but the subscription is still active,
|
||||
i.e. next_bill_date > now"""
|
||||
|
12
cron.py
12
cron.py
@ -63,8 +63,16 @@ def notify_premium_end():
|
||||
send_email(
|
||||
user.email,
|
||||
f"Your subscription will end soon {user.name}",
|
||||
render("transactional/subscription-end.txt", user=user),
|
||||
render("transactional/subscription-end.html", user=user),
|
||||
render(
|
||||
"transactional/subscription-end.txt",
|
||||
user=user,
|
||||
next_bill_date=sub.next_bill_date.strftime("%Y-%m-%d"),
|
||||
),
|
||||
render(
|
||||
"transactional/subscription-end.html",
|
||||
user=user,
|
||||
next_bill_date=sub.next_bill_date.strftime("%Y-%m-%d"),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
{{ render_text("Hi,") }}
|
||||
{% endif %}
|
||||
|
||||
{{ render_text("Your subscription will end on " + user.next_bill_date() + ".") }}
|
||||
{{ render_text("Your subscription will end on " + next_bill_date + ".") }}
|
||||
|
||||
{{ render_text("When the subscription ends:") }}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
Hi {{user.name}}
|
||||
|
||||
Your subscription will end on {{ user.next_bill_date() }}.
|
||||
Your subscription will end on {{ next_bill_date }}.
|
||||
|
||||
When the subscription ends:
|
||||
|
||||
|
@ -28,9 +28,11 @@
|
||||
{% if current_user.in_trial() %}
|
||||
<small class="text-success d-block mt-1">Trial ends {{ current_user.trial_end|dt }}</small>
|
||||
{% elif current_user.is_premium() %}
|
||||
|
||||
<small class="text-success d-block mt-1">Premium
|
||||
{% if current_user.is_cancel() %}
|
||||
until {{ current_user.next_bill_date() }}
|
||||
{% set sub = current_user.get_subscription() %}
|
||||
{% if sub and sub.cancelled %}
|
||||
until {{ sub.next_bill_date.strftime("%Y-%m-%d") }}
|
||||
{% endif %}
|
||||
</small>
|
||||
{% endif %}
|
||||
|
Loading…
Reference in New Issue
Block a user