mirror of https://github.com/zulip/zulip.git
org settings: Add organization profile preview option.
This should make it convenient and obvious how verify that their organization profile looks nice after being markdown-rendered. Fixes #12105.
This commit is contained in:
parent
e87d468f76
commit
3e50ed2075
|
@ -495,6 +495,7 @@ input[type=checkbox] + .inline-block {
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#id_org_profile_preview,
|
||||||
.realm-icon-section {
|
.realm-icon-section {
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,10 @@
|
||||||
id="realm_icon_delete_button">{{t 'Delete profile picture' }}</button>
|
id="realm_icon_delete_button">{{t 'Delete profile picture' }}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<a href="/login/?preview=true" target="_blank" class="button rounded sea-green w-200 block" id="id_org_profile_preview">
|
||||||
|
{{t 'Preview organization profile' }}
|
||||||
|
<i class="fa fa-external-link" aria-hidden="true" title="{{t 'Preview organization profile' }}"></i>
|
||||||
|
</a>
|
||||||
|
|
||||||
<div class="subsection-header">
|
<div class="subsection-header">
|
||||||
<h3>{{t "Organization logo" }}
|
<h3>{{t "Organization logo" }}
|
||||||
|
|
|
@ -216,6 +216,31 @@ class AuthBackendTest(ZulipTestCase):
|
||||||
password,
|
password,
|
||||||
realm=get_realm("zulip")))
|
realm=get_realm("zulip")))
|
||||||
|
|
||||||
|
def test_login_preview(self) -> None:
|
||||||
|
# Test preview=true displays organization login page
|
||||||
|
# instead of redirecting to app
|
||||||
|
self.login(self.example_email("iago"))
|
||||||
|
realm = get_realm("zulip")
|
||||||
|
result = self.client_get('/login/?preview=true')
|
||||||
|
self.assertEqual(result.status_code, 200)
|
||||||
|
self.assert_in_response(realm.description, result)
|
||||||
|
self.assert_in_response(realm.name, result)
|
||||||
|
self.assert_in_response("Log in to Zulip", result)
|
||||||
|
|
||||||
|
data = dict(description=ujson.dumps("New realm description"),
|
||||||
|
name=ujson.dumps("New Zulip"))
|
||||||
|
result = self.client_patch('/json/realm', data)
|
||||||
|
self.assert_json_success(result)
|
||||||
|
|
||||||
|
result = self.client_get('/login/?preview=true')
|
||||||
|
self.assertEqual(result.status_code, 200)
|
||||||
|
self.assert_in_response("New realm description", result)
|
||||||
|
self.assert_in_response("New Zulip", result)
|
||||||
|
|
||||||
|
result = self.client_get('/login/')
|
||||||
|
self.assertEqual(result.status_code, 302)
|
||||||
|
self.assertEqual(result.url, 'http://zulip.testserver')
|
||||||
|
|
||||||
@override_settings(AUTHENTICATION_BACKENDS=('zproject.backends.ZulipDummyBackend',))
|
@override_settings(AUTHENTICATION_BACKENDS=('zproject.backends.ZulipDummyBackend',))
|
||||||
def test_no_backend_enabled(self) -> None:
|
def test_no_backend_enabled(self) -> None:
|
||||||
result = self.client_get('/login/')
|
result = self.client_get('/login/')
|
||||||
|
|
|
@ -689,10 +689,16 @@ class TwoFactorLoginView(BaseTwoFactorLoginView):
|
||||||
return super().done(form_list, **kwargs)
|
return super().done(form_list, **kwargs)
|
||||||
|
|
||||||
def login_page(request: HttpRequest, **kwargs: Any) -> HttpResponse:
|
def login_page(request: HttpRequest, **kwargs: Any) -> HttpResponse:
|
||||||
|
# To support previewing the Zulip login pages, we have a special option
|
||||||
|
# that disables the default behavior of redirecting logged-in users to the
|
||||||
|
# logged-in app.
|
||||||
|
is_preview = False
|
||||||
|
if request.method == "GET" and request.GET and request.GET.get('preview'):
|
||||||
|
is_preview = True
|
||||||
if settings.TWO_FACTOR_AUTHENTICATION_ENABLED:
|
if settings.TWO_FACTOR_AUTHENTICATION_ENABLED:
|
||||||
if request.user and request.user.is_verified():
|
if request.user and request.user.is_verified():
|
||||||
return HttpResponseRedirect(request.user.realm.uri)
|
return HttpResponseRedirect(request.user.realm.uri)
|
||||||
elif request.user.is_authenticated:
|
elif request.user.is_authenticated and not is_preview:
|
||||||
return HttpResponseRedirect(request.user.realm.uri)
|
return HttpResponseRedirect(request.user.realm.uri)
|
||||||
if is_subdomain_root_or_alias(request) and settings.ROOT_DOMAIN_LANDING_PAGE:
|
if is_subdomain_root_or_alias(request) and settings.ROOT_DOMAIN_LANDING_PAGE:
|
||||||
redirect_url = reverse('zerver.views.registration.realm_redirect')
|
redirect_url = reverse('zerver.views.registration.realm_redirect')
|
||||||
|
|
Loading…
Reference in New Issue