Gérer l'affichage d'un abonnement expiré (statut Frisbii "expired")

_show_active_view affichait par erreur la vue "abonnement actif" (avec un
faux "Prochaine facturation") pour un abonnement expiré. Un abonnement
expiré bascule maintenant sur l'écran de re-souscription, avec une alerte
dédiée. Jamais remarqué jusqu'ici car les webhooks Frisbii ne remontaient
pas ce changement de statut.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Colin Maudry
2026-07-02 18:13:12 +02:00
parent 1159697c0e
commit 14ae1a7bfb
2 changed files with 11 additions and 4 deletions
+8 -2
View File
@@ -151,7 +151,7 @@ def _active_view(row):
blocks.append( blocks.append(
dbc.Alert(f"Abonnement résilié, actif jusqu'au {end}.", color="warning") dbc.Alert(f"Abonnement résilié, actif jusqu'au {end}.", color="warning")
) )
else: elif row["status"] == "active":
blocks.append(html.P(f"Prochaine facturation : {end}")) blocks.append(html.P(f"Prochaine facturation : {end}"))
if row["status"] in ("pending", "trial", "active"): if row["status"] in ("pending", "trial", "active"):
@@ -278,7 +278,7 @@ def _tous_abonnes_banner():
def _show_active_view(row) -> bool: def _show_active_view(row) -> bool:
return row is not None and row["status"] != "failed" return row is not None and row["status"] not in ("failed", "expired")
def layout(**query): def layout(**query):
@@ -301,6 +301,12 @@ def layout(**query):
body.append(_active_view(row)) body.append(_active_view(row))
body.append(_resiliation_modal(row["current_period_end"])) body.append(_resiliation_modal(row["current_period_end"]))
else: else:
if row is not None and row["status"] == "expired":
body.append(
dbc.Alert(
"Votre abonnement a expiré.", color="warning", className="mb-4"
)
)
body.extend([_plan_cards(trial_used=trial_used), _explainer()]) body.extend([_plan_cards(trial_used=trial_used), _explainer()])
body.append(_salaire_modal) body.append(_salaire_modal)
@@ -82,12 +82,13 @@ def test_banner_absent_when_flag_off(monkeypatch):
def test_show_active_view_true_for_live_statuses(monkeypatch): def test_show_active_view_true_for_live_statuses(monkeypatch):
from src.pages.compte import abonnement as compte_abonnement from src.pages.compte import abonnement as compte_abonnement
for status in ("pending", "trial", "active", "cancelled", "expired"): for status in ("pending", "trial", "active", "cancelled"):
assert compte_abonnement._show_active_view({"status": status}) is True assert compte_abonnement._show_active_view({"status": status}) is True
def test_show_active_view_false_for_failed_or_none(monkeypatch): def test_show_active_view_false_for_failed_expired_or_none(monkeypatch):
from src.pages.compte import abonnement as compte_abonnement from src.pages.compte import abonnement as compte_abonnement
assert compte_abonnement._show_active_view({"status": "failed"}) is False assert compte_abonnement._show_active_view({"status": "failed"}) is False
assert compte_abonnement._show_active_view({"status": "expired"}) is False
assert compte_abonnement._show_active_view(None) is False assert compte_abonnement._show_active_view(None) is False