Skip to content

Commit

Permalink
Merge d289d56 into 68c3a48
Browse files Browse the repository at this point in the history
  • Loading branch information
therealmarv committed Jan 26, 2017
2 parents 68c3a48 + d289d56 commit 384da02
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
23 changes: 23 additions & 0 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2110,3 +2110,26 @@ Gives you the privacy policy for your PYBOSSA
"template": "help/privacy.html",
"title": "Privacy Policy"
}
Help cookie policy
~~~~~~~~~~~~~~~~~~
**Endpoint: /help/cookies-policy**
*Allowed methods*: **GET**
**GET**
Gives you the cookie policy for your PYBOSSA
* **content**: Simplified HTML of rendered cookie policy.
* **template**: The Jinja2 template that could be rendered.
* **title**: the title for the endpoint.
**Example output**
.. code-block:: python
{
"content": "<html><body><p>cookie policy here</p></body></html>"
"template": "help/cookies_policy.html",
"title": "Help: Cookies Policy"
}
7 changes: 5 additions & 2 deletions pybossa/view/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ def tos():
@blueprint.route('/cookies-policy')
def cookies_policy():
"""Render help/cookies-policy page."""
return render_template('help/cookies_policy.html',
title='Help: Cookies Policy')
cleaned_up_content = Document(render_template('help/cookies_policy.html')).summary()
response = dict(template='help/cookies_policy.html',
content=cleaned_up_content,
title='Help: Cookies Policy')
return handle_content_type(response)


@blueprint.route('/privacy')
Expand Down
18 changes: 16 additions & 2 deletions test/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -4208,12 +4208,26 @@ def test_59_help_tos(self):
assert "Terms for use" in res.data, err_msg

@with_context
def test_59_help_policy(self):
"""Test WEB help policy page exists."""
def test_59_help_cookies_policy(self):
"""Test WEB help cookies policy page exists."""
url = "/help/cookies-policy"
res = self.app.get(url, follow_redirects=True)
err_msg = "There should be a TOS page"
assert "uses cookies" in res.data, err_msg
assert_raises(ValueError, json.loads, res.data)

@with_context
def test_59_help_cookies_policy_json(self):
"""Test WEB help cookies policy json endpoint exists."""
url = "/help/cookies-policy"
res = self.app_get_json(url)
data = json.loads(res.data)
err_msg = 'Template wrong'
assert data['template'] == 'help/cookies_policy.html', err_msg
err_msg = 'Title wrong'
assert data['title'] == 'Help: Cookies Policy', err_msg
err_msg = "There should be HTML content"
assert '<body' in data['content'], err_msg

@with_context
def test_59_help_privacy(self):
Expand Down

0 comments on commit 384da02

Please sign in to comment.