Skip to content

Commit

Permalink
portico: Provide isolated single-page versions of /terms and /privacy .
Browse files Browse the repository at this point in the history
The `isolated_page` context flag we rely on was added in the
parent commit.
  • Loading branch information
gnprice authored and timabbott committed Jan 29, 2020
1 parent bcbc8f2 commit a5aa541
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
15 changes: 15 additions & 0 deletions zerver/tests/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,3 +560,18 @@ def test_custom_privacy_policy_template_with_absolute_url(self) -> None:
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)
12 changes: 12 additions & 0 deletions zerver/views/portico.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)})
4 changes: 2 additions & 2 deletions zproject/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,8 @@
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',),
Expand Down

0 comments on commit a5aa541

Please sign in to comment.