changes to the bookingflow

This commit is contained in:
2026-10-02 18:37:02 +02:00
parent e24a74f7a2
commit a40b081c14
3 changed files with 44 additions and 16 deletions
+35 -15
View File
@@ -2168,7 +2168,8 @@ def download_sample():
@app.route('/preise', methods=['GET'])
def preise():
return render_template("preise.html")
trial_instance = _get_user_trial_instance(session.get("username")) if session.get("username") else None
return render_template("preise.html", trial_instance=trial_instance)
@app.route('/preise/book-option', methods=['POST'])
@@ -2696,6 +2697,36 @@ def _user_has_used_trial(username: str) -> bool:
client.close()
return False
def _get_user_trial_instance(username: str) -> dict | None:
if not username:
return None
client, collection = _get_collection("instances")
try:
instance = collection.find_one(
{
"$or": [
{"owner_username": username, "is_trial": True},
{"owner_username": username, "trial_state": {"$exists": True}},
]
},
sort=[("updated_at", -1), ("created_at", -1)],
)
finally:
client.close()
if not instance:
return None
return {
"_id": instance.get("_id"),
"school_name": _sanitize_text(instance.get("school_name") or "Ihre Schule", 120),
"subdomain": _sanitize_text(instance.get("subdomain") or "", 63),
"domain": _sanitize_text(instance.get("domain") or "", 190),
"trial_state": _sanitize_text(instance.get("trial_state") or "", 40),
"is_active": bool(instance.get("is_trial") and instance.get("trial_state") in {"active", "in_progress", "expired"}),
}
@app.route('/booking/payment', methods=['GET', 'POST'])
@login_required
def booking_payment():
@@ -2711,15 +2742,8 @@ def booking_payment():
is_trial = booking_flow in {"trial", "testversion"} or requested_trial or package_requests_trial
trial_days = int(request.values.get("trial_days") or 14)
active_trial_client, active_trial_col = _get_collection("instances")
try:
active_trial = active_trial_col.find_one({
"owner_username": session.get("username"),
"is_trial": True,
"trial_state": {"$in": ["active", "in_progress", "expired"]},
})
finally:
active_trial_client.close()
trial_instance = _get_user_trial_instance(session.get("username"))
active_trial = trial_instance if trial_instance and trial_instance.get("is_active") else None
if is_trial and _user_has_used_trial(session.get("username") or ""):
error_message = "Diese Testversion wurde für Ihr Konto bereits aktiviert. Bitte wenden Sie sich zum Upgrade an unser Team."
@@ -2792,11 +2816,7 @@ def booking_payment():
"username": session.get("username"),
"display_name": session.get("display_name") or session.get("username"),
"form_data": form_data,
"active_trial": {
"school_name": active_trial.get("school_name") if active_trial else "",
"domain": active_trial.get("domain") if active_trial else "",
"expires_at": active_trial.get("expires_at") if active_trial else "",
} if active_trial and not is_trial else None,
"active_trial": trial_instance if trial_instance and not is_trial else None,
}
if request.method == "GET":
+8
View File
@@ -145,6 +145,14 @@
<p>Nach Ihrer Anfrage meldet sich unser Admin-Team, um die Bereitstellung oder einen Termin zur Abstimmung einzuplanen. Die Server stehen in einem deutschen Rechenzentrum (Strato) – DSGVO-konform und hochverfügbar.</p>
</section>
{% if trial_instance %}
<div class="notice" style="margin-bottom: 1.8rem; border-color: #b9d8c2; background: #f1fbf3;">
<strong>Ihre bisherige Testinstanz bleibt erhalten.</strong>
<span> Aktuelle Schul-URL: <a href="https://{{ trial_instance.domain or trial_instance.subdomain ~ '.invario-software.de' }}" target="_blank" rel="noopener noreferrer">{{ trial_instance.domain or trial_instance.subdomain ~ '.invario-software.de' }}</a>.</span>
<span> Wenn Sie ein Modul oder Paket buchen, werden Ihre bestehenden Daten und diese Subdomain weiterverwendet.</span>
</div>
{% endif %}
<section class="packages-grid" aria-label="Buchungspakete">
<!-- TESTVERSION -->
<article class="package-card">
+1 -1
View File
@@ -303,7 +303,7 @@
{% if active_trial %}
<div class="booking-review__note" style="margin-top: 1rem; border-color: #b9d8c2; background: #f1fbf3;">
Ihre aktive Testversion ({{ active_trial.school_name or 'Ihre Schule' }}) wird bei dieser Buchung weiterverwendet und mit den ausgewählten Modulen reaktiviert. Die bisherigen Zugangsdaten und die Schul-URL bleiben erhalten.
Ihre Testversion ({{ active_trial.school_name or 'Ihre Schule' }}) wird bei dieser Buchung weiterverwendet und mit den ausgewählten Modulen reaktiviert. Aktuelle Schul-URL: <strong>{{ active_trial.domain or active_trial.subdomain ~ '.invario-software.de' }}</strong>. Ihre bisherigen Zugangsdaten, Daten und diese Subdomain bleiben erhalten.
</div>
{% endif %}