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.

accounts/deactivated: Show deactivated_redirect url if present

Siddharth Asthanadaac7536f388
diff --git a/templates/zerver/deactivated.html b/templates/zerver/deactivated.html
index 3dc3989408a..484ef71f917 100644
--- a/templates/zerver/deactivated.html
+++ b/templates/zerver/deactivated.html
@@ -19,6 +19,13 @@
<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>.
+ {% endtrans %}
+ {% endif %}
+ {% trans %}
Please contact <a href="mailto:{{ support_email }}">{{ support_email }}</a> to reactivate
this group.
{% endtrans %}
diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.py
index 9551e15ad04..73cb2b35d8a 100644
--- a/zerver/tests/test_signup.py
+++ b/zerver/tests/test_signup.py
@@ -171,6 +171,16 @@ class DeactivationNoticeTestCase(ZulipTestCase):
result = self.client_get('/accounts/deactivated/')
self.assertIn("Zulip Dev, 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:
+ realm = get_realm("zulip")
+ realm.deactivated = True
+ realm.deactivated_redirect = "http://example.zulipchat.com"
+ realm.save(update_fields=["deactivated", "deactivated_redirect"])
+
+ result = self.client_get('/accounts/deactivated/')
+ self.assertIn('It has moved to <a href="http://example.zulipchat.com">http://example.zulipchat.com</a>.', result.content.decode())
class AddNewUserHistoryTest(ZulipTestCase):
def test_add_new_user_history_race(self) -> None:
diff --git a/zerver/views/auth.py b/zerver/views/auth.py
index a513cf7118d..04f30efce3d 100644
--- a/zerver/views/auth.py
+++ b/zerver/views/auth.py
@@ -601,8 +601,11 @@ def redirect_to_misconfigured_ldap_notice(request: HttpResponse, error_type: int
def show_deactivation_notice(request: HttpRequest) -> HttpResponse:
realm = get_realm_from_request(request)
if realm and realm.deactivated:
+ context = {"deactivated_domain_name": realm.name}
+ if realm.deactivated_redirect is not None:
+ context["deactivated_redirect"] = realm.deactivated_redirect
return render(request, "zerver/deactivated.html",
- context={"deactivated_domain_name": realm.name})
+ context=context)
return HttpResponseRedirect(reverse('login_page'))