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