mirror of
https://github.com/simple-login/app.git
synced 2024-09-29 21:21:29 +02:00
reformat code: put POST handling on top
This commit is contained in:
parent
a0bb4e9ccc
commit
c3cd1419f9
@ -85,27 +85,40 @@ def create_zendesk_request(email: str, content: str, files: [FileStorage]) -> bo
|
|||||||
methods=["POST"],
|
methods=["POST"],
|
||||||
deduct_when=lambda r: hasattr(g, "deduct_limit") and g.deduct_limit,
|
deduct_when=lambda r: hasattr(g, "deduct_limit") and g.deduct_limit,
|
||||||
)
|
)
|
||||||
def process_support_dialog():
|
def support_route():
|
||||||
if not ZENDESK_HOST:
|
if not ZENDESK_HOST:
|
||||||
return render_template("dashboard/support_disabled.html")
|
flash("Support isn't enabled", "error")
|
||||||
if request.method == "GET":
|
return redirect(url_for("dashboard.index"))
|
||||||
return render_template(
|
|
||||||
"dashboard/support.html", ticket_email=current_user.email
|
if request.method == "POST":
|
||||||
)
|
|
||||||
content = request.form.get("ticket_content")
|
content = request.form.get("ticket_content")
|
||||||
email = request.form.get("ticket_email")
|
email = request.form.get("ticket_email")
|
||||||
|
|
||||||
if not content:
|
if not content:
|
||||||
flash("Please add a description", "error")
|
flash("Please add a description", "error")
|
||||||
return render_template("dashboard/support.html", ticket_email=email)
|
return render_template("dashboard/support.html", ticket_email=email)
|
||||||
|
|
||||||
if not email:
|
if not email:
|
||||||
flash("Please add an email", "error")
|
flash("Please provide an email address", "error")
|
||||||
return render_template("dashboard/support.html", ticket_content=content)
|
return render_template("dashboard/support.html", ticket_content=content)
|
||||||
|
|
||||||
if not create_zendesk_request(
|
if not create_zendesk_request(
|
||||||
email, content, request.files.getlist("ticket_files")
|
email, content, request.files.getlist("ticket_files")
|
||||||
):
|
):
|
||||||
|
flash(
|
||||||
|
"Cannot create a Zendesk ticket, sorry for the inconvenience! Please retry later.",
|
||||||
|
"error",
|
||||||
|
)
|
||||||
return render_template(
|
return render_template(
|
||||||
"dashboard/support.html", ticket_email=email, ticket_content=content
|
"dashboard/support.html", ticket_email=email, ticket_content=content
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# only enable rate limiting for successful Zendesk ticket creation
|
||||||
g.deduct_limit = True
|
g.deduct_limit = True
|
||||||
flash("Ticket created. You should have received an email notification.", "success")
|
flash(
|
||||||
|
"Support ticket is created. You will receive an email about its status.",
|
||||||
|
"success",
|
||||||
|
)
|
||||||
return redirect(url_for("dashboard.index"))
|
return redirect(url_for("dashboard.index"))
|
||||||
|
|
||||||
|
return render_template("dashboard/support.html", ticket_email=current_user.email)
|
||||||
|
Loading…
Reference in New Issue
Block a user