feat(abonnement): bouton changer de méthode de paiement sur /compte/abonnement
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -82,6 +82,23 @@ def _active_view(row):
|
||||
elif row["status"] == "active":
|
||||
blocks.append(html.P(f"Prochaine facturation : {end}"))
|
||||
|
||||
if row["status"] in ("trial", "active"):
|
||||
blocks.append(
|
||||
html.Form(
|
||||
method="POST",
|
||||
action="/subscriptions/change-payment-method",
|
||||
children=[
|
||||
_csrf_input(),
|
||||
html.Button(
|
||||
"Changer de méthode de paiement",
|
||||
type="submit",
|
||||
className="btn btn-outline-secondary mt-3 me-2",
|
||||
),
|
||||
],
|
||||
style={"display": "inline-block"},
|
||||
)
|
||||
)
|
||||
|
||||
if row["status"] in ("pending", "trial", "active"):
|
||||
blocks.append(
|
||||
html.Button(
|
||||
@@ -152,6 +169,10 @@ def _feedback(query):
|
||||
out.append(dbc.Alert(text, color=color))
|
||||
if query.get("resiliation") == "ok":
|
||||
out.append(dbc.Alert("Votre abonnement a été résilié.", color="info"))
|
||||
if query.get("carte") == "succes":
|
||||
out.append(dbc.Alert("Méthode de paiement mise à jour.", color="success"))
|
||||
if query.get("carte") == "annule":
|
||||
out.append(dbc.Alert("Modification annulée.", color="secondary"))
|
||||
if query.get("error") == "frisbii":
|
||||
out.append(
|
||||
dbc.Alert(
|
||||
|
||||
@@ -66,3 +66,63 @@ def test_show_active_view_false_for_failed_expired_or_none(monkeypatch):
|
||||
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
|
||||
|
||||
|
||||
def test_active_view_shows_change_payment_method_for_active():
|
||||
from src.pages.compte import abonnement as compte_abonnement
|
||||
|
||||
row = {
|
||||
"plan": "simple",
|
||||
"status": "active",
|
||||
"current_period_end": "2099-01-01T00:00:00+00:00",
|
||||
}
|
||||
text = str(compte_abonnement._active_view(row))
|
||||
assert "Changer de méthode de paiement" in text
|
||||
assert "/subscriptions/change-payment-method" in text
|
||||
|
||||
|
||||
def test_active_view_shows_change_payment_method_for_trial():
|
||||
from src.pages.compte import abonnement as compte_abonnement
|
||||
|
||||
row = {
|
||||
"plan": "simple",
|
||||
"status": "trial",
|
||||
"current_period_end": "2099-01-01T00:00:00+00:00",
|
||||
}
|
||||
assert "Changer de méthode de paiement" in str(compte_abonnement._active_view(row))
|
||||
|
||||
|
||||
def test_active_view_hides_change_payment_method_for_cancelled():
|
||||
from src.pages.compte import abonnement as compte_abonnement
|
||||
|
||||
row = {
|
||||
"plan": "simple",
|
||||
"status": "cancelled",
|
||||
"current_period_end": "2099-01-01T00:00:00+00:00",
|
||||
}
|
||||
assert "Changer de méthode de paiement" not in str(
|
||||
compte_abonnement._active_view(row)
|
||||
)
|
||||
|
||||
|
||||
def test_active_view_hides_change_payment_method_for_pending():
|
||||
from src.pages.compte import abonnement as compte_abonnement
|
||||
|
||||
row = {"plan": "simple", "status": "pending", "current_period_end": None}
|
||||
text = str(compte_abonnement._active_view(row))
|
||||
assert "Changer de méthode de paiement" not in text
|
||||
assert "Ajouter une méthode de paiement" in text
|
||||
|
||||
|
||||
def test_feedback_carte_succes():
|
||||
from src.pages.compte import abonnement as compte_abonnement
|
||||
|
||||
text = str(compte_abonnement._feedback({"carte": "succes"}))
|
||||
assert "Méthode de paiement mise à jour." in text
|
||||
|
||||
|
||||
def test_feedback_carte_annule():
|
||||
from src.pages.compte import abonnement as compte_abonnement
|
||||
|
||||
text = str(compte_abonnement._feedback({"carte": "annule"}))
|
||||
assert "Modification annulée." in text
|
||||
|
||||
Reference in New Issue
Block a user