Skip to content

Commit

Permalink
Merge pull request #1435 from Scifabric/issue-1394-help-terms
Browse files Browse the repository at this point in the history
Issue 1394 help terms
  • Loading branch information
therealmarv committed Jan 31, 2017
2 parents 68c3a48 + 6d2756d commit 45d61ca
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
24 changes: 24 additions & 0 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2110,3 +2110,27 @@ Gives you the privacy policy for your PYBOSSA
"template": "help/privacy.html",
"title": "Privacy Policy"
}
Help terms of use
~~~~~~~~~~~~~~~~~
**Endpoint: /help/terms-of-use**
*Allowed methods*: **GET**
**GET**
Gives you the terms of use for your PYBOSSA
* **content**: Simplified HTML of rendered terms of use.
* **template**: The Jinja2 template that could be rendered.
* **title**: the title for the endpoint.
**Example output**
.. code-block:: python
{
"content": "<html><body><p>Terms of use text</p></body></html>"
"template": "help/tos.html",
"title": "Help: Terms of Use"
}
6 changes: 5 additions & 1 deletion pybossa/view/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ def license():
@blueprint.route('/terms-of-use')
def tos():
"""Render help/terms-of-use page."""
return render_template('help/tos.html', title='Help: Terms of Use')
cleaned_up_content = Document(render_template('help/tos.html')).summary()
response = dict(template='help/tos.html',
content=cleaned_up_content,
title='Help: Terms of Use')
return handle_content_type(response)


@blueprint.route('/cookies-policy')
Expand Down
14 changes: 14 additions & 0 deletions test/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -4206,6 +4206,20 @@ def test_59_help_tos(self):
res = self.app.get(url, follow_redirects=True)
err_msg = "There should be a TOS page"
assert "Terms for use" in res.data, err_msg
assert_raises(ValueError, json.loads, res.data)

@with_context
def test_59_help_tos_json(self):
"""Test WEB help TOS json endpoint exists"""
url = "/help/terms-of-use"
res = self.app_get_json(url)
data = json.loads(res.data)
err_msg = 'Template wrong'
assert data['template'] == 'help/tos.html', err_msg
err_msg = 'Title wrong'
assert data['title'] == 'Help: Terms of Use', err_msg
err_msg = "There should be HTML content"
assert '<body' in data['content'], err_msg

@with_context
def test_59_help_policy(self):
Expand Down

0 comments on commit 45d61ca

Please sign in to comment.