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.

portico: Improve message for deactivated, invalid and moved orgs.

Alya Abbott5aeeafd39cfc
diff --git a/templates/zerver/deactivated.html b/templates/zerver/deactivated.html
index 4354715dd95..02637bfe291 100644
--- a/templates/zerver/deactivated.html
+++ b/templates/zerver/deactivated.html
@@ -16,23 +16,33 @@
<div class="inline-block">
<div class="get-started">
- <h1>{{ _("Deactivated organization") }}</h1>
+ {% if deactivated_redirect %}
+ <h1>{{ _("Organization moved") }}</h1>
+ {% else %}
+ <h1>{{ _("Deactivated organization") }}</h1>
+ {% endif %}
</div>
<div class="white-box deactivated-realm-container">
<p>
- {% trans %}
- The organization you are trying to join, {{ deactivated_domain_name }}, has been deactivated.
- {% endtrans %}
{% if deactivated_redirect %}
{% trans %}
- It has moved to <a href="{{ deactivated_redirect }}">{{ deactivated_redirect }}</a>.
+ This organization has moved to <a href="{{ deactivated_redirect }}">{{ deactivated_redirect }}</a>.
{% endtrans %}
+ {% else %}
+ {% trans %}
+ This organization has been deactivated.
+ {% endtrans %}
+ {% if is_self_hosting_management_page %}
+ {% trans %}
+ If you are an owner of this organization, you can <a href="mailto:{{ support_email }}">contact this Zulip server's administrators</a> to reactivate it.
+ {% endtrans %}
+ {% else %}
+ {% trans %}
+ If you are an owner of this organization, you can <a href="mailto:{{ support_email }}">contact Zulip support</a> to reactivate it.
+ {% endtrans %}
+ {% endif %}
{% endif %}
- {% trans %}
- Please contact <a href="mailto:{{ support_email }}">{{ support_email }}</a> to reactivate
- this group.
- {% endtrans %}
</p>
</div>
diff --git a/templates/zerver/invalid_realm.html b/templates/zerver/invalid_realm.html
index 6cc4ef5b60b..5f353c564fb 100644
--- a/templates/zerver/invalid_realm.html
+++ b/templates/zerver/invalid_realm.html
@@ -1,21 +1,27 @@
{% extends "zerver/portico.html" %}
{% block title %}
-<title>{{ _("Organization does not exist") }} | Zulip</title>
+<title>{{ _("No organization found") }} | Zulip</title>
{% endblock %}
{% block portico_content %}
-<div class="app find-account-page flex full-page">
+<div class="app find-account-page flex full-page account-creation">
<div class="inline-block new-style">
<div class="lead">
- <h1 class="get-started">{{ _('Organization does not exist') }}…</h1>
+ <h1 class="get-started">{{ _('No organization found') }}</h1>
</div>
<div class="app-main white-box">
- {{ _('Hi there! Thank you for your interest in Zulip.') }}
- <br />
- {% trans %}There is no Zulip organization hosted at this subdomain.{% endtrans %}
+ <p>
+ {% trans %}There is no Zulip organization at <b>{{ current_url }}</b>.{% endtrans %}
+ <br />
+ {% if is_self_hosting_management_page %}
+ {% trans %}Please try a different URL, or <a href="mailto:{{ support_email }}">contact this Zulip server's administrators</a>.{% endtrans %}
+ {% else %}
+ {% trans %}Please try a different URL, or <a href="mailto:{{ support_email }}">contact Zulip support</a>.{% endtrans %}
+ {% endif %}
+ </p>
</div>
</div>
</div>
diff --git a/zerver/middleware.py b/zerver/middleware.py
index d7f8b7ec1f2..d51c869dbea 100644
--- a/zerver/middleware.py
+++ b/zerver/middleware.py
@@ -569,7 +569,10 @@ class HostDomainMiddleware(MiddlewareMixin):
# organizations even if it does not host a realm.
return None
- return render(request, "zerver/invalid_realm.html", status=404)
+ context = {
+ "current_url": request.get_host(),
+ }
+ return render(request, "zerver/invalid_realm.html", status=404, context=context)
set_tag("realm", request_notes.realm.string_id)
diff --git a/zerver/tests/test_auth_backends.py b/zerver/tests/test_auth_backends.py
index 0c9f0a4d0d8..7066ffb19f3 100644
--- a/zerver/tests/test_auth_backends.py
+++ b/zerver/tests/test_auth_backends.py
@@ -1220,7 +1220,7 @@ class SocialAuthBase(DesktopFlowTestingLib, ZulipTestCase, ABC):
def test_user_cannot_log_into_nonexisting_realm(self) -> None:
account_data_dict = self.get_account_data_dict(email=self.email, name=self.name)
result = self.social_auth_test(account_data_dict, subdomain="nonexistent")
- self.assert_in_response("There is no Zulip organization hosted at this subdomain.", result)
+ self.assert_in_response("There is no Zulip organization at", result)
self.assertEqual(result.status_code, 404)
def test_user_cannot_log_into_wrong_subdomain(self) -> None:
diff --git a/zerver/tests/test_decorators.py b/zerver/tests/test_decorators.py
index 5cd7625e676..3eb5663cc03 100644
--- a/zerver/tests/test_decorators.py
+++ b/zerver/tests/test_decorators.py
@@ -1568,9 +1568,7 @@ class TestRequestNotes(ZulipTestCase):
with mock.patch("zerver.views.home.zulip_login_required") as mock_home_real:
result = self.client_get("/", subdomain="invalid")
self.assertEqual(result.status_code, 404)
- self.assert_in_response(
- "There is no Zulip organization hosted at this subdomain.", result
- )
+ self.assert_in_response("There is no Zulip organization at", result)
mock_home_real.assert_not_called()
diff --git a/zerver/tests/test_docs.py b/zerver/tests/test_docs.py
index 15cb2e96d80..8183a7ac881 100644
--- a/zerver/tests/test_docs.py
+++ b/zerver/tests/test_docs.py
@@ -516,7 +516,7 @@ class PlansPageTest(ZulipTestCase):
non_existent_domain = "moo"
result = self.client_get("/plans/", subdomain=non_existent_domain)
self.assertEqual(result.status_code, 404)
- self.assert_in_response("does not exist", result)
+ self.assert_in_response("There is no Zulip organization at", result)
realm = get_realm("zulip")
realm.plan_type = Realm.PLAN_TYPE_STANDARD_FREE
diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.py
index b9bf9fc0160..e6b7e234644 100644
--- a/zerver/tests/test_signup.py
+++ b/zerver/tests/test_signup.py
@@ -169,7 +169,7 @@ class DeactivationNoticeTestCase(ZulipTestCase):
result = self.client_get("/login/", follow=True)
self.assertEqual(result.redirect_chain[-1], ("/accounts/deactivated/", 302))
- self.assertIn("Zulip Dev, has been deactivated.", result.content.decode())
+ self.assertIn("This organization has been deactivated.", result.content.decode())
self.assertNotIn("It has moved to", result.content.decode())
def test_deactivation_notice_when_deactivated_and_deactivated_redirect_is_set(self) -> None:
@@ -180,7 +180,7 @@ class DeactivationNoticeTestCase(ZulipTestCase):
result = self.client_get("/login/", follow=True)
self.assertIn(
- 'It has moved to <a href="http://example.zulipchat.com">http://example.zulipchat.com</a>.',
+ 'This organization has moved to <a href="http://example.zulipchat.com">http://example.zulipchat.com</a>.',
result.content.decode(),
)
@@ -190,7 +190,7 @@ class DeactivationNoticeTestCase(ZulipTestCase):
result = self.client_get("/login/", follow=True)
self.assertIn(
- 'It has moved to <a href="http://new-subdomain-name.testserver">http://new-subdomain-name.testserver</a>.',
+ 'This organization has moved to <a href="http://new-subdomain-name.testserver">http://new-subdomain-name.testserver</a>.',
result.content.decode(),
)
@@ -215,7 +215,7 @@ class DeactivationNoticeTestCase(ZulipTestCase):
result = self.client_get("/login/", follow=True)
self.assertIn(
- 'It has moved to <a href="http://new-name-1.testserver">http://new-name-1.testserver</a>.',
+ 'This organization has moved to <a href="http://new-name-1.testserver">http://new-name-1.testserver</a>.',
result.content.decode(),
)
@@ -223,7 +223,7 @@ class DeactivationNoticeTestCase(ZulipTestCase):
do_change_realm_subdomain(realm, "new-name-2", acting_user=None)
result = self.client_get("/login/", follow=True)
self.assertIn(
- 'It has moved to <a href="http://new-name-2.testserver">http://new-name-2.testserver</a>.',
+ 'This organization has moved to <a href="http://new-name-2.testserver">http://new-name-2.testserver</a>.',
result.content.decode(),
)
@@ -660,7 +660,8 @@ class PasswordResetTest(ZulipTestCase):
# check the redirect link telling you to check mail for password reset link
self.assertEqual(result.status_code, 404)
- self.assert_in_response("There is no Zulip organization hosted at this subdomain.", result)
+ self.assert_in_response("There is no Zulip organization at", result)
+ self.assert_in_response("Please try a different URL", result)
from django.core.mail import outbox
@@ -899,7 +900,8 @@ class LoginTest(ZulipTestCase):
def test_login_invalid_subdomain(self) -> None:
result = self.login_with_return(self.example_email("hamlet"), "xxx", subdomain="invalid")
self.assertEqual(result.status_code, 404)
- self.assert_in_response("There is no Zulip organization hosted at this subdomain.", result)
+ self.assert_in_response("There is no Zulip organization at", result)
+ self.assert_in_response("Please try a different URL", result)
self.assert_logged_in_user_id(None)
def test_register(self) -> None:
diff --git a/zerver/views/home.py b/zerver/views/home.py
index f932c811940..5ea485048aa 100644
--- a/zerver/views/home.py
+++ b/zerver/views/home.py
@@ -160,7 +160,10 @@ def home(request: HttpRequest) -> HttpResponse:
return redirect(reverse("remote_billing_legacy_server_login"))
realm = get_realm_from_request(request)
if realm is None:
- return render(request, "zerver/invalid_realm.html", status=404)
+ context = {
+ "current_url": request.get_host(),
+ }
+ return render(request, "zerver/invalid_realm.html", status=404, context=context)
if realm.allow_web_public_streams_access():
return web_public_view(home_real)(request)
return zulip_login_required(home_real)(request)