fix(subscriptions): un abonnement en échec (failed) ne bloque plus le réabonnement

This commit is contained in:
Colin Maudry
2026-07-01 16:56:34 +02:00
parent 872fc33dd7
commit 126834c7d4
2 changed files with 20 additions and 2 deletions
+6 -2
View File
@@ -294,12 +294,16 @@ def _tous_abonnes_banner():
)
def _show_active_view(row) -> bool:
return row is not None and row["status"] != "failed"
def layout(**query):
guard = account_guard("/compte/abonnement", require_subscription=False)
if guard is not None:
return guard
row = db.get_by_user(current_user.id) if current_user.is_authenticated else None
row = db.get_current(current_user.id) if current_user.is_authenticated else None
trial_used = (
db.has_used_trial(current_user.id) if current_user.is_authenticated else False
)
@@ -310,7 +314,7 @@ def layout(**query):
body.append(banner)
body.extend(_feedback(query))
if row is not None:
if _show_active_view(row):
body.append(_active_view(row))
body.append(_resiliation_modal(row["current_period_end"]))
else:
@@ -77,3 +77,17 @@ def test_banner_absent_when_flag_off(monkeypatch):
from src.pages import compte_abonnement
assert compte_abonnement._tous_abonnes_banner() is None
def test_show_active_view_true_for_live_statuses(monkeypatch):
from src.pages import compte_abonnement
for status in ("pending", "trial", "active", "cancelled", "expired"):
assert compte_abonnement._show_active_view({"status": status}) is True
def test_show_active_view_false_for_failed_or_none(monkeypatch):
from src.pages import compte_abonnement
assert compte_abonnement._show_active_view({"status": "failed"}) is False
assert compte_abonnement._show_active_view(None) is False