accounts/deactivated: Show deactivated_redirect url if present

If a user visits a realm which has been deactivated and it's
deactivated_redirect field is set, we should have a message telling the
user that the realm has moved to the deactivated_redirect url.
This commit is contained in:
Siddharth Asthana 2020-12-12 16:53:48 +05:30 committed by Alex Vandiver
parent 82f5759299
commit daac7536f3
3 changed files with 21 additions and 1 deletions

View File

@ -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 %}

View File

@ -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:

View File

@ -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'))