Adaptation de l'effet de TOUS_ABONNES
This commit is contained in:
@@ -95,6 +95,7 @@ def _subscribe_button(
|
||||
authenticated: bool, has_active_subscription: bool, tous_abonnes: bool
|
||||
):
|
||||
if tous_abonnes:
|
||||
href = "/compte/abonnement" if authenticated else "/inscription"
|
||||
return html.Div(
|
||||
[
|
||||
dbc.Alert(
|
||||
@@ -104,9 +105,9 @@ def _subscribe_button(
|
||||
color="info",
|
||||
),
|
||||
html.A(
|
||||
"Je m'abonne",
|
||||
href="#",
|
||||
className="btn btn-secondary disabled",
|
||||
"Je m'abonne gratuitement",
|
||||
href=href,
|
||||
className="btn btn-secondary",
|
||||
),
|
||||
],
|
||||
className="text-center my-4",
|
||||
|
||||
@@ -41,6 +41,39 @@ def _reabo_button():
|
||||
)
|
||||
|
||||
|
||||
def _free_access_view():
|
||||
from src.pages.a_propos.abonnement import abonnement_features
|
||||
|
||||
return html.Div(
|
||||
[
|
||||
html.H3(
|
||||
"Vous avez temporairement accès à toutes les fonctionnalités",
|
||||
className="mb-3",
|
||||
),
|
||||
html.P("Votre accès gratuit débloque :"),
|
||||
abonnement_features,
|
||||
dcc.Markdown(
|
||||
"Pensez à copier les liens vers vos vues pour les conserver si vous "
|
||||
"ne comptez pas souscrire à un abonnement payant.",
|
||||
className="text-muted mt-3",
|
||||
),
|
||||
],
|
||||
className="mb-4",
|
||||
)
|
||||
|
||||
|
||||
def _no_sub_view(tous_abonnes: bool, row):
|
||||
if tous_abonnes:
|
||||
return _free_access_view()
|
||||
blocks = []
|
||||
if row is not None and row["status"] == "expired":
|
||||
blocks.append(
|
||||
dbc.Alert("Votre abonnement a expiré.", color="warning", className="mb-4")
|
||||
)
|
||||
blocks.append(_reabo_button())
|
||||
return html.Div(blocks)
|
||||
|
||||
|
||||
def _active_view(row):
|
||||
meta = plans.plan_meta(row["plan"]) or {"label": row["plan"]}
|
||||
end = format_date_french(row["current_period_end"])
|
||||
@@ -262,13 +295,9 @@ def layout(**query):
|
||||
body.append(_active_view(row))
|
||||
body.append(_resiliation_modal(row["current_period_end"]))
|
||||
else:
|
||||
if row is not None and row["status"] == "expired":
|
||||
body.append(
|
||||
dbc.Alert(
|
||||
"Votre abonnement a expiré.", color="warning", className="mb-4"
|
||||
)
|
||||
)
|
||||
body.append(_reabo_button())
|
||||
from src.utils import TOUS_ABONNES
|
||||
|
||||
body.append(_no_sub_view(TOUS_ABONNES, row))
|
||||
|
||||
body.append(_salaire_modal)
|
||||
return account_shell("abonnement", html.Div(body))
|
||||
|
||||
@@ -191,6 +191,15 @@ def _cgu_modal():
|
||||
|
||||
|
||||
def layout(**query):
|
||||
from src.utils import TOUS_ABONNES
|
||||
|
||||
# Sous TOUS_ABONNES, la souscription payante est désactivée : cette page
|
||||
# carte bancaire n'a plus de sens, on renvoie vers la page abonnement.
|
||||
if TOUS_ABONNES:
|
||||
return dcc.Location(
|
||||
href="/compte/abonnement", id="mes-infos-tous-abonnes-redirect"
|
||||
)
|
||||
|
||||
guard = account_guard("/compte/abonnement/mes-infos", require_subscription=False)
|
||||
if guard is not None:
|
||||
return guard
|
||||
|
||||
@@ -23,10 +23,17 @@ ERROR_MESSAGES = {
|
||||
|
||||
|
||||
def layout(error: str | None = None, email: str | None = None, **_):
|
||||
from src.utils import TOUS_ABONNES
|
||||
|
||||
alert = None
|
||||
if error and error in ERROR_MESSAGES:
|
||||
alert = dbc.Alert(ERROR_MESSAGES[error], color="danger")
|
||||
|
||||
# Sous TOUS_ABONNES, on saute la page carte bancaire (mes-infos).
|
||||
linkedin_next = (
|
||||
"/compte/abonnement" if TOUS_ABONNES else "/compte/abonnement/mes-infos"
|
||||
)
|
||||
|
||||
return dbc.Container(
|
||||
className="py-4",
|
||||
style={"maxWidth": "500px"},
|
||||
@@ -70,7 +77,7 @@ def layout(error: str | None = None, email: str | None = None, **_):
|
||||
],
|
||||
),
|
||||
html.Div("ou", className="text-center text-muted my-2"),
|
||||
linkedin_button("/compte/abonnement/mes-infos"),
|
||||
linkedin_button(linkedin_next),
|
||||
html.Hr(),
|
||||
dcc.Link("Déjà un compte ? Se connecter", href="/connexion"),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user