mirror of https://github.com/zulip/zulip.git
config_error: Support passing arguments specifying the "go back" link.
Depending on the kind of config error being shown, different "go back" links may be more appropriate. We probably hard-coded /login/ for it, because these config errors are most commonly used for authentication backend config error, where it makes sense to have /login/ as "go back", because the user most likely indeed got there from the login page. However, for remote_billing_bouncer_not_configured, it doesn't make sense, because the user almost surely is already logged in and got there by clicking "Plan management" inside the gear menu in the logged in app.
This commit is contained in:
parent
e952c3b627
commit
c1857b2c86
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
<p>After making your changes, remember to restart
|
<p>After making your changes, remember to restart
|
||||||
the Zulip server.</p>
|
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>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,12 +1,22 @@
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.http import HttpRequest, HttpResponse
|
from django.http import HttpRequest, HttpResponse
|
||||||
from django.shortcuts import render
|
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
|
assert "/" not in error_name
|
||||||
context = {
|
context = {
|
||||||
"error_name": error_name,
|
"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:
|
if settings.DEVELOPMENT:
|
||||||
context["auth_settings_path"] = "zproject/dev-secrets.conf"
|
context["auth_settings_path"] = "zproject/dev-secrets.conf"
|
||||||
|
|
|
@ -234,4 +234,9 @@ def self_hosting_auth_not_configured(request: HttpRequest) -> HttpResponse:
|
||||||
# is actually real.
|
# is actually real.
|
||||||
return render(request, "404.html", status=404)
|
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",
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue