portico: Provide isolated single-page versions of /terms and /privacy .

The `isolated_page` context flag we rely on was added in the
parent commit.
This commit is contained in:
Greg Price
2020-01-28 15:05:06 -08:00
committed by Tim Abbott
parent bcbc8f2bd5
commit a5aa541999
3 changed files with 29 additions and 2 deletions

View File

@@ -560,3 +560,18 @@ class PrivacyTermsTest(ZulipTestCase):
with self.settings(PRIVACY_POLICY=abs_path):
response = self.client_get('/privacy/')
self.assert_in_success_response(['This is some <em>bold text</em>.'], response)
def test_no_nav(self) -> None:
# Test that our ?nav=0 feature of /privacy and /terms,
# designed to comply with the Apple App Store draconian
# policies that ToS/Privacy pages linked from an iOS app have
# no links to the rest of the site if there's pricing
# information for anything elsewhere on the site.
response = self.client_get("/terms/")
self.assert_in_success_response(["Plans"], response)
response = self.client_get("/terms/?nav=no")
self.assert_not_in_success_response(["Plans"], response)
response = self.client_get("/privacy/?nav=no")
self.assert_not_in_success_response(["Plans"], response)

View File

@@ -39,3 +39,15 @@ def team_view(request: HttpRequest) -> HttpResponse:
'date': data['date'],
},
)
def get_isolated_page(request: HttpRequest) -> bool:
'''Accept a GET param `?nav=no` to render an isolated, navless page.'''
return request.GET.get('nav') == 'no'
def terms_view(request: HttpRequest) -> HttpResponse:
return render(request, 'zerver/terms.html',
context={'isolated_page': get_isolated_page(request)})
def privacy_view(request: HttpRequest) -> HttpResponse:
return render(request, 'zerver/privacy.html',
context={'isolated_page': get_isolated_page(request)})

View File

@@ -563,8 +563,8 @@ i18n_urls = [
url(r'^atlassian/$', TemplateView.as_view(template_name='zerver/atlassian.html')),
# Terms of Service and privacy pages.
url(r'^terms/$', TemplateView.as_view(template_name='zerver/terms.html'), name='terms'),
url(r'^privacy/$', TemplateView.as_view(template_name='zerver/privacy.html'), name='privacy'),
url(r'^terms/$', zerver.views.portico.terms_view, name='terms'),
url(r'^privacy/$', zerver.views.portico.privacy_view, name='privacy'),
url(r'^config-error/google$', TemplateView.as_view(
template_name='zerver/config_error.html',),