Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

config_error: Support passing arguments specifying the "go back" link.

Mateusz Manderac1857b2c8671
diff --git a/templates/zerver/config_error/container.html b/templates/zerver/config_error/container.html
index 7d07c29715a..05aa2860984 100644
--- a/templates/zerver/config_error/container.html
+++ b/templates/zerver/config_error/container.html
@@ -22,7 +22,7 @@
<p>After making your changes, remember to restart
the Zulip server.</p>
- <p><a href=""> Refresh</a> to try again or <a href="/login/">click here</a> to go back to the login page.</p>
+ <p><a href=""> Refresh</a> to try again or <a href="{{ go_back_to_url }}">go back to {{ go_back_to_url_name }}</a>.</p>
</div>
</div>
diff --git a/zerver/views/errors.py b/zerver/views/errors.py
index 62938116805..3a745ad29e5 100644
--- a/zerver/views/errors.py
+++ b/zerver/views/errors.py
@@ -1,12 +1,22 @@
+from typing import Optional
+
from django.conf import settings
from django.http import HttpRequest, HttpResponse
from django.shortcuts import render
-def config_error(request: HttpRequest, error_name: str) -> HttpResponse:
+def config_error(
+ request: HttpRequest,
+ error_name: str,
+ *,
+ go_back_to_url: Optional[str] = None,
+ go_back_to_url_name: Optional[str] = None,
+) -> HttpResponse:
assert "/" not in error_name
context = {
"error_name": error_name,
+ "go_back_to_url": go_back_to_url or "/login/",
+ "go_back_to_url_name": go_back_to_url_name or "the login page",
}
if settings.DEVELOPMENT:
context["auth_settings_path"] = "zproject/dev-secrets.conf"
diff --git a/zerver/views/push_notifications.py b/zerver/views/push_notifications.py
index 9308ed4474d..18048df9948 100644
--- a/zerver/views/push_notifications.py
+++ b/zerver/views/push_notifications.py
@@ -234,4 +234,9 @@ def self_hosting_auth_not_configured(request: HttpRequest) -> HttpResponse:
# is actually real.
return render(request, "404.html", status=404)
- return config_error(request, "remote_billing_bouncer_not_configured")
+ return config_error(
+ request,
+ "remote_billing_bouncer_not_configured",
+ go_back_to_url="/",
+ go_back_to_url_name="the app",
+ )